DWG DXFをPDFに変換するC# | Auto CADファイルをPDF JPEG PNGに変換するC# .NET

C#でDWGまたはDXFをPNG JPEG BMP GIF またはTIFFに変換する

Aspose.CAD for .NETは、AutoCAD図面フォーマット(DXFおよびDWG)をPNG, BMP, TIFF, JPEGおよびGIFに変換できます。この目的を達成するために、効率的で使いやすいAPIが公開されています。

サポートされている任意のAutoCAD図面フォーマットをラスタ画像フォーマットに変換するには、以下の簡単な手順を参照してください。

  1. AutoCAD DWGまたはDXFファイルをImageクラスに読み込みます。
  2. CadRasterizationOptionsのインスタンスを作成します。
  3. PageWidthおよびPageHeightを使用して画像のサイズを設定/変更します。
  4. ImageOptionsBaseのインスタンスを作成します。
  5. 前のステップで作成されたCadRasterizationOptionsVectorRasterizationOptionsプロパティに設定します。
  6. Image.Saveを使用してAutoCAD図面をPDFとして保存し、ファイルパス(またはMemoryStreamのオブジェクト)と前のステップで作成されたImageOptionsBaseのインスタンスを渡します。

これが完全なソースコードです。

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath))
{
// Create an instance of CadRasterizationOptions
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
// Set page width & height
rasterizationOptions.PageWidth = 1200;
rasterizationOptions.PageHeight = 1200;
// Create an instance of PngOptions for the resultant image
ImageOptionsBase options = new Aspose.CAD.ImageOptions.PngOptions();
// Set rasterization options
options.VectorRasterizationOptions = rasterizationOptions;
MyDir = MyDir + "conic_pyramid_raster_image_out.png";
// Save resultant image
image.Save(MyDir, options);
}

デフォルトでは、APIは「Model」レイアウトのみをレンダリングします。ただし、CAD図面を画像フォーマットに変換する際に、選択したレイアウトも指定できます。

CAD変換のカスタマイズ

CADからPDFおよびCADからラスタ画像への変換手順は非常に構成可能です。なぜなら、CadRasterizationOptionsクラスは、設定に応じてアプリケーションのニーズに応じてレンダリングプロセスをオーバーライドする多くのオプション機能を提供するように実装されているからです。

CadRasterizationOptionsクラス

CadRasterizationOptionsクラスは、DWGやDXFなどのすべてのサポートされているCADフォーマットに共通であるため、この記事で共有されている情報は前述のCADフォーマットの両方に対して有効です。

最も便利なCadRasterizationOptionsクラスのプロパティは次のとおりです。

プロパティデフォルト値必須説明
PageWidth0はいページの幅を指定します。
PageHeight0はいページの高さを指定します。
ScaleMethodScaleType.ShrinkToFitいいえ図面が自動的にスケーリングされるべきかどうかを指定します。デフォルト値は、画像をキャンバスサイズに合わせて自動的に縮小します。GrowToFitモードに切り替えるか、None設定を使用して自動スケーリングを無効にします。
BackgroundColorColor.Whiteいいえ出力画像の背景色を指定します。
DrawTypeCadDrawTypeMode.UseDrawColorいいえエンティティの着色モードを指定します。エンティティをそのネイティブカラーで描画するにはUseObjectColorオプションを指定し、ネイティブカラーをオーバーライドするにはUseDrawColorオプションを指定します。
DrawColorColor.Blackいいえオーバーライドされたエンティティの色を指定します(DrawTypeUseDrawColorプロパティ値に設定されている場合のみ)。
AutomaticLayoutsScalingいいえ自動レイアウトスケーリングを実行する必要があるかどうかを指定します。

キャンバスサイズとモードの設定

CADからPDFまたはCADからラスタ画像フォーマットへのエクスポートは簡単な作業ではありません。生成されるPDFまたは画像には、図面を適切にレンダリングするためにキャンバスサイズを定義する必要があるため、PDFページの出力寸法を指定する必要があります。CadRasterizationOptions.PageWidthCadRasterizationOptions.PageHeightプロパティを明示的に設定するか、そうでない場合はImageSaveExceptionを取得する可能性があります。

さらに、寸法スケールオプションを指定できます。スケーリングオプションはCadRasterizationOptions.ScaleMethodプロパティによって設定されます。このオプションを使用して、画像の寸法をCadRasterizationOptions.PageWidthおよびCadRasterizationOptions.PageHeightの値に自動的に調整できます。デフォルトではCadRasterizationOptions.ScaleMethodScaleType.ShrinkToFitモードに設定されています。このプロパティは次の動作を定義します。

  • CAD図面の寸法が結果キャンバスサイズより大きい場合、図面の寸法はアスペクト比を保持しながら、結果キャンバスに収まるように減少されます。
  • CAD図面の寸法が結果キャンバスサイズより小さい場合、CadRasterizationOptions.ScaleMethodプロパティをScaleType.GrowToFitに設定して、図面サイズをPDFキャンバスに収まるように増加させますが、アスペクト比は保持します。
  • またはScaleType.Noneオプションで自動スケーリングを無効にします。

以下のコードサンプルでは、自動スケーリングオプションの使用を示しています。

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath))
{
// Create an instance of CadRasterizationOptions and set its various properties
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
rasterizationOptions.PageWidth = 1600;
rasterizationOptions.PageHeight = 1600;
rasterizationOptions.AutomaticLayoutsScaling = true;
rasterizationOptions.NoScaling = false;
// Create an instance of PdfOptions
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.VectorRasterizationOptions = rasterizationOptions;
//Export CAD to PDF
image.Save(MyDir + "result_out.pdf", pdfOptions);
// Create an instance of TiffOptions
Aspose.CAD.ImageOptions.TiffOptions tiffOptions = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Set the VectorRasterizationOptions property
tiffOptions.VectorRasterizationOptions = rasterizationOptions;
//Export CAD to TIFF
image.Save(MyDir + "result_out.tiff", tiffOptions);
}

背景および描画色の設定

デフォルトでは、生成されるキャンバスのカラーパレットは一般的なドキュメントスキームに設定されています。つまり、CAD図面内のすべてのエンティティは、無地の白い背景に黒いペンで描画されます。これらの設定は、CadRasterizationOptions.BackgroundColorおよびCadRasterizationOptions.DrawColorプロパティで変更できます。CadRasterizationOptions.DrawColorプロパティを変更するには、描画色を使用するようにするためにCadRasterizationOptions.DrawTypeプロパティを設定する必要があります。CadRasterizationOptions.DrawTypeプロパティは、CADエンティティが色を保持するか、カスタム色に変換されるかを制御します。エンティティの色を保持するには、CadRasterizationOptions.DrawTypeCadDrawTypeMode.UseObjectColorとして指定します。それ以外の場合は、CadDrawTypeMode.UseDrawColor値を指定します。

以下のコードサンプルでは、異なる色プロパティの使用方法を示しています。

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath))
{
// Create an instance of CadRasterizationOptions and set its various properties
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
rasterizationOptions.PageWidth = 1600;
rasterizationOptions.PageHeight = 1600;
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.Beige;
rasterizationOptions.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseDrawColor;
rasterizationOptions.DrawColor = Aspose.CAD.Color.Blue;
// Create an instance of PdfOptions
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.VectorRasterizationOptions = rasterizationOptions;
//Export CAD to PDF
image.Save(MyDir + "result_out.pdf", pdfOptions);
// Create an instance of TiffOptions
Aspose.CAD.ImageOptions.TiffOptions tiffOptions = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Set the VectorRasterizationOptions property
tiffOptions.VectorRasterizationOptions = rasterizationOptions;
//Export CAD to TIFF
image.Save(MyDir + "result_out.tiff", tiffOptions);
}

自動レイアウトスケーリングの設定

ほとんどのCAD図面には、1つのファイルに複数のレイアウトが保存されており、それぞれのレイアウトの寸法が異なる場合があります。そのため、そのようなCAD図面をPDFにレンダリングする際、PDFの各ページはレイアウトサイズに応じて異なるスケーリングを持つ可能性があります。レンダリングを均一にするために、Aspose.CAD APIはCadRasterizationOptions.AutomaticLayoutsScalingプロパティを公開しています。デフォルト値はfalseですが、trueの場合、APIは各レイアウトに対応するスケールを検索し、ページサイズに応じて自動的に再サイズ操作を実行して描画します。

以下がCadRasterizationOptions.AutomaticLayoutsScalingプロパティがCadRasterizationOptions.ScaleMethodプロパティと組み合わせてどのように機能するかです。

  1. ScaleMethodScaleType.ShrinkToFitまたはScaleType.GrowToFitに設定され、AutomaticLayoutsScalingがfalseに設定されている場合、すべてのレイアウト(モデルを含む)は最初のオプションに従って処理されます。
  2. ScaleMethodScaleType.ShrinkToFitまたはScaleType.GrowToFitに設定され、AutomaticLayoutsScalingがtrueに設定されている場合、すべてのレイアウト(モデルを除く)はそれぞれのサイズに応じて処理され、一方でモデルは最初のオプションに従って処理されます。
  3. ScaleMethodScaleType.Noneに設定され、AutomaticLayoutsScalingがtrueまたはfalseに設定されている場合は、スケーリングは行われません。

以下のコードサンプルでは、CADからPDFへの変換のために自動レイアウトスケーリングを設定する方法を示しています。

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath))
{
// Create an instance of CadRasterizationOptions and set its various properties
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
rasterizationOptions.PageWidth = 1600;
rasterizationOptions.PageHeight = 1600;
// Set Auto Layout Scaling
rasterizationOptions.AutomaticLayoutsScaling = true;
// Create an instance of PdfOptions
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.VectorRasterizationOptions = rasterizationOptions;
MyDir = MyDir + "result_out.pdf";
//Export the CAD to PDF
image.Save(MyDir, pdfOptions);
}

C#でAutoCAD DXFまたはDWGレイアウトをPNGまたは他の画像フォーマットに変換する

Aspose.CAD for .NET APIは、DXFやDWGなどのサポートされているフォーマットのCADレイアウトをPNG BMP TIFF JPEGおよびGIFに変換できます。このAPIは、CAD図面の特定のレイアウトを異なるPSDレイヤーにレンダリングするサポートも提供します。

以下の簡単な手順で同様のことを達成できます。

  • Imageクラスを使用してAutoCAD DWGまたはDXFファイルを読み込みます。
  • 画像の幅と高さを設定/変更します。
  • CadRasterizationOptions.Layoutsプロパティを使用して、希望するレイアウト名を設定します。
  • ImageOptionsBaseのインスタンスを作成し、そのVectorRasterizationOptionsプロパティを前のステップで作成したCadRasterizationOptionsのインスタンスに設定します。
  • CADレイアウトをTIFFまたは画像として保存します。

これが完全なソースコードです。

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath))
{
// Create an instance of CadRasterizationOptions
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
// Set page width & height
rasterizationOptions.PageWidth = 1200;
rasterizationOptions.PageHeight = 1200;
// Specify a list of layout names
rasterizationOptions.Layouts = new string[] { "Model", "Layout1" };
// Create an instance of TiffOptions for the resultant image
ImageOptionsBase options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Set rasterization options
options.VectorRasterizationOptions = rasterizationOptions;
MyDir = MyDir + "conic_pyramid_layoutstorasterimage_out.tiff";
// Save resultant image
image.Save(MyDir, options);
}

CADレンダリングプロセスの追跡を有効にする

Aspose.CADは、CADレンダリングプロセスの追跡を支援するために、一連のクラスとサポートする列挙フィールドを導入しました。これらの変更により、CADからPDFへの変換を行う際に追跡を有効にすることができます。

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath))
{
MemoryStream stream = new MemoryStream();
Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions();
// Create an instance of CadRasterizationOptions and set its various properties
Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
pdfOptions.VectorRasterizationOptions = cadRasterizationOptions;
cadRasterizationOptions.PageWidth = 800;
cadRasterizationOptions.PageHeight = 600;
image.Save(stream, pdfOptions);
}

CADレンダリングプロセスの追跡では、以下の問題を検出できます。

  1. ヘッダー情報が欠落または破損しています。
  2. レイアウト情報が欠落しています。
  3. ブロックエンティティが欠落しています。
  4. 寸法スタイルが欠落しています。
  5. スタイルが欠落しています。

CAD図面を変換する際のフォントの置き換え

特定のCAD図面が、CADからPDFまたはCADからラスタ画像への変換が行われているマシンで利用できない特定のフォントを使用している場合があります。そのような状況では、Aspose.CAD APIは適切な例外をトリガーして欠落しているフォントを強調し、変換プロセスを停止します。APIは、これらのフォントを使用して、生成されるPDFや画像に正しく内容をレンダリングする必要があります。

Aspose.CAD APIは、必要なフォントを利用可能なフォントに置き換えるメカニズムを簡単に使用できる方法を提供しています。CadImage.Stylesプロパティは、CAD図面の各スタイルのCadStyleTableObjectを含むCadStylesDictionaryのインスタンスを返します。CadStyleTableObject.PrimaryFontNameを使用して利用可能なフォント名を指定できます。

以下のコードスニペットは、Aspose.CAD for .NET APIを使用してCAD図面内のすべてのスタイルのフォントを変更する方法を示しています。

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
// Load a CAD drawing in an instance of CadImage
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
{
// Iterate over the items of CadStyleDictionary
foreach (CadStyleTableObject style in cadImage.Styles)
{
// Set the font name
style.PrimaryFontName = "Arial";
}
}
Console.WriteLine("\nFont changed successfully.");
}
public static void SubstitutingFontByName()
{
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
// Load a CAD drawing in an instance of CadImage
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
{
// Iterate over the items of CadStyleDictionary
foreach (CadStyleTableObject style in cadImage.Styles)
{
if (style.StyleName == "Roman")
{
// Specify the font for one particular style
style.PrimaryFontName = "Arial";
}
}
}
}

特定のスタイル名を介してアクセスすることにより、特定のスタイルのフォントを変更することも可能です。以下のコードスニペットは、このアプローチの使用方法を示しています。

// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
// Load a CAD drawing in an instance of CadImage
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
{
// Iterate over the items of CadStyleDictionary
foreach (CadStyleTableObject style in cadImage.Styles)
{
if (style.StyleName == "Roman")
{
// Specify the font for one particular style
style.PrimaryFontName = "Arial";
}
}
}

CADレイヤーをラスタ画像フォーマットに変換する

Aspose.CAD for .NET APIは、必要なCADレイヤーの名前を指定し、ラスタ画像フォーマットにレンダリングするための効率的で使いやすい手段を公開しています。以下の5つの簡単な手順で同様のことを達成できます。

  1. ファクトリメソッドLoadを使用してCADファイルをImageのインスタンスに読み込みます。
  2. CadRasterizationOptionsのインスタンスを作成し、PageWidthおよびPageHeightなどの必須プロパティを設定します。
  3. CadRasterizationOptions.Layers.Addメソッドを使用して、希望するレイヤー名を追加します。
  4. ImageOptionsBaseのインスタンスを作成し、そのVectorRasterizationOptionsプロパティを、前のステップで作成したCadRasterizationOptionsのインスタンスに設定します。
  5. Image.Saveメソッドを呼び出し、ファイルパス(またはMemoryStreamのオブジェクト)と前のステップで作成したImageOptionsBaseのインスタンスを渡します。

これが完全なソースコードです。

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
// Load a CAD drawing in an instance of Image
using (var image = Aspose.CAD.Image.Load(sourceFilePath))
{
// Create an instance of CadRasterizationOptions
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
// Set image width & height
rasterizationOptions.PageWidth = 500;
rasterizationOptions.PageHeight = 500;
// Add the layer name to the CadRasterizationOptions's layer list
rasterizationOptions.Layers= new string[] { "LayerA" };
// Create an instance of JpegOptions (or any ImageOptions for raster formats)
var options = new Aspose.CAD.ImageOptions.JpegOptions();
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions
options.VectorRasterizationOptions = rasterizationOptions;
//Export each layer to Jpeg format
MyDir = MyDir + "CADLayersToRasterImageFormats_out.jpg";
image.Save(MyDir, options);
}
Console.WriteLine("\nCAD layers converted successfully to raster image format.\nFile saved at " + MyDir);
}
public static void ConvertAllLayersToRasterImageFormats()
{
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
// Load a CAD drawing in an instance of CadImage
using (var image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
{
// Create an instance of CadRasterizationOptions
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
// Set image width & height
rasterizationOptions.PageWidth = 500;
rasterizationOptions.PageHeight = 500;
// Get the layers in an instance of CadLayersDictionary
var layersList = image.Layers;
// Iterate over the layers
foreach (var layerName in layersList.GetLayersNames())
{
// Display layer name for tracking
Console.WriteLine("Start with " + layerName);
// Add the layer name to the CadRasterizationOptions's layer list
rasterizationOptions.Layers = new string[] { "LayerA" };
// Create an instance of JpegOptions (or any ImageOptions for raster formats)
var options = new Aspose.CAD.ImageOptions.JpegOptions();
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions
options.VectorRasterizationOptions = rasterizationOptions;
//Export each layer to Jpeg format
image.Save(layerName + "_out.jpg", options);
}
}
Console.WriteLine("\nCAD all layers converted successfully to raster image format.");

すべてのCADレイヤーを別々の画像に変換する

CadImage.Layersを使用してCAD図面からすべてのレイヤーを取得し、以下のように各レイヤーを別の画像としてレンダリングできます。

// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-.NET
// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string sourceFilePath = MyDir + "conic_pyramid.dxf";
// Load a CAD drawing in an instance of CadImage
using (var image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
{
// Create an instance of CadRasterizationOptions
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
// Set image width & height
rasterizationOptions.PageWidth = 500;
rasterizationOptions.PageHeight = 500;
// Set the drawing to render at the center of image
rasterizationOptions.CenterDrawing = true;
// Get the layers in an instance of CadLayersDictionary
var layersList = image.Layers;
// Iterate over the layers
foreach (var layerName in layersList.GetLayersNames())
{
// Display layer name for tracking
Console.WriteLine("Start with " + layerName);
// Add the layer name to the CadRasterizationOptions's layer list
rasterizationOptions.Layers.Add(layerName);
// Create an instance of JpegOptions (or any ImageOptions for raster formats)
var options = new Aspose.CAD.ImageOptions.JpegOptions();
// Set VectorRasterizationOptions property to the instance of CadRasterizationOptions
options.VectorRasterizationOptions = rasterizationOptions;
//Export each layer to Jpeg format
image.Save(layerName + "_out.jpg", options);
}
}

DWF CADレイヤーをラスタ画像フォーマットに変換する

Aspose.CAD for .NET APIは、必要なCADレイヤーの名前を指定し、ラスタ画像フォーマットにレンダリングするための効率的で使いやすい手段を公開しています。以下の5つの簡単な手順で同様のことを達成できます。

  1. ファクトリメソッドLoadを使用してDWF CADファイルをImageのインスタンスに読み込みます。
  2. CadRasterizationOptionsのインスタンスを作成し、PageWidthおよびPageHeightなどの必須プロパティを設定します。
  3. CadRasterizationOptions.Layers.Addメソッドを使用して希望するレイヤー名を追加します。
  4. ImageOptionsBaseのインスタンスを作成し、そのVectorRasterizationOptionsプロパティを前のステップで作成したCadRasterizationOptionsのインスタンスに設定します。
  5. Image.Saveメソッドを呼び出し、ファイルパス(またはMemoryStreamのオブジェクト)と前のステップで作成したImageOptionsBaseのインスタンスを渡します。

これが完全なソースコードです。

// The path to the documents directory.
string MyDir = RunExamples.GetDataDir_ConvertingCAD();
string inputFile = MyDir + "18-12-11 9644 - site.dwf";
using (Image image = Image.Load(inputFile))
{
BmpOptions bmpOptions = new BmpOptions();
var dwfRasterizationOptions = new CadRasterizationOptions();
bmpOptions.VectorRasterizationOptions = dwfRasterizationOptions;
dwfRasterizationOptions.PageHeight = 500;
dwfRasterizationOptions.PageWidth = 500;
// export
string outPath = MyDir + "18-12-11 9644 - site.bmp";
image.Save(outPath, bmpOptions);
}

Aspose.CAD for .NETは、APIとバージョン番号に関する情報を出力ドキュメントに直接書き込みます。たとえば、ドキュメントをPDFにレンダリングすると、Aspose.CAD for .NETは、アプリケーションフィールドに「Aspose.CAD」、PDFプロデューサーフィールドに「Aspose.CAD v 17.10」のような値をポピュレートします。

この情報を出力ドキュメントから変更または削除するようにAspose.CAD for .NETに指示することはできませんのでご注意ください。