Dibujos SVG
Contents
[
Hide
]Exportar formato SVG a PDF
Aspose.CAD para .NET permite a los desarrolladores exportar un archivo SVG a formato PDF. El enfoque de conversión de SVG a PDF funciona de la siguiente manera:
- Cargar el archivo de dibujo SVG usando el método de fábrica Image.Load.
- Crear un objeto de la clase CadRasterizationOptions y establecer las propiedades PageHeight y PageWidth.
- Crear un objeto de la clase PdfOptions y establecer la propiedad VectorRasterizationOptions.
- Llamar a Image.Save pasando un objeto de PdfOptions como segundo parámetro.
Código de muestra
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); | |
} |