Disegni SVG
Contents
[
Hide
]Esportazione del formato SVG in PDF
Aspose.CAD per .NET consente agli sviluppatori di esportare un file SVG in formato PDF. L’approccio di conversione da SVG a PDF funziona come segue:
- Caricare il file di disegno SVG utilizzando il metodo di fabbrica Image.Load.
- Creare un oggetto della classe CadRasterizationOptions e impostare le proprietà PageHeight e PageWidth.
- Creare un oggetto della classe PdfOptions e impostare la proprietà VectorRasterizationOptions.
- Chiamare Image.Save passando un oggetto di PdfOptions come secondo parametro.
Codice di esempio
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); | |
} |