ציורים ב-SVG

ייצוא פורמט SVG ל-PDF

Aspose.CAD עבור .NET מאפשר ל developers לייצא קובץ SVG לפורמט PDF. גישת ההמרה מ-SVG ל-PDF פועלת כך:

  1. טען את קובץ הציור SVG באמצעות שיטת ה-factory Image.Load.
  2. צור אובייקט של המחלקה CadRasterizationOptions והגדר את המאפיינים PageHeight ו-PageWidth.
  3. צור אובייקט של המחלקה PdfOptions והגדר את המאפיין VectorRasterizationOptions.
  4. קרא ל-Image.Save תוך כדי העברת אובייקט של PdfOptions כפרמטר השני.

קוד לדוגמה

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);
}