SVG-Zeichnungen
Contents
[
Hide
]Exportieren von SVG-Format nach PDF
Aspose.CAD für .NET ermöglicht Entwicklern, eine SVG-Datei in das PDF -Format zu exportieren. Der Ansatz zur Konvertierung von SVG in PDF funktioniert wie folgt:
- Laden Sie die SVG-Zeichnungsdatei mit der Image.Load -Fabrikmethode.
- Erstellen Sie ein Objekt der Klasse CadRasterizationOptions und setzen Sie die Eigenschaften PageHeight und PageWidth.
- Erstellen Sie ein Objekt der Klasse PdfOptions und setzen Sie die Eigenschaft VectorRasterizationOptions.
- Rufen Sie Image.Save auf und übergeben Sie ein Objekt der PdfOptions -Klasse als zweiten Parameter.
Beispielcode
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); | |
} |