Dessins SVG
Contents
[
Hide
]Exportation au format SVG vers PDF
Aspose.CAD pour .NET permet aux développeurs d’exporter un fichier SVG au format PDF. L’approche de conversion SVG en PDF fonctionne de la manière suivante :
- Chargez le fichier de dessin SVG en utilisant la méthode usin de Image.Load.
- Créez un objet de la classe CadRasterizationOptions et définissez les propriétés PageHeight et PageWidth.
- Créez un objet de la classe PdfOptions et définissez la propriété VectorRasterizationOptions.
- Appelez Image.Save tout en passant un objet de PdfOptions comme deuxième paramètre.
Exemple de Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string inputFile ="file.svg"; | |
using (Image image = Image.Load(inputFile)) | |
{ | |
// Initialize PdfOptions class object | |
PdfOptions options = new PdfOptions(); | |
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); | |
cadRasterizationOptions.PageHeight = 500; | |
cadRasterizationOptions.PageWidth = 500; | |
options.VectorRasterizationOptions = cadRasterizationOptions; | |
// Export SVG to PDF | |
string outPath = "output.pdf"; | |
image.Save(outPath, options); | |
} |