SVG 図形
Contents
[
Hide
]SVG形式をPDFにエクスポートする
Aspose.CAD for .NETは、開発者がSVGファイルをPDF形式にエクスポートすることを可能にします。SVGからPDFへの変換アプローチは以下のように動作します:
- Image.Loadファクトリメソッドを使用してSVG図面ファイルを読み込みます。
- CadRasterizationOptionsクラスのオブジェクトを作成し、PageHeightおよびPageWidthプロパティを設定します。
- PdfOptionsクラスのオブジェクトを作成し、VectorRasterizationOptionsプロパティを設定します。
- Image.Saveを呼び出し、PdfOptionsのオブジェクトを第二引数として渡します。
サンプルコード
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); | |
} |