Chỉ định chế độ kết xuất cho tệp DWG và DXF

Cách chỉ định chế độ kết xuất cho tệp DWG và DXF

Vấn đề: Cách chỉ định chế độ kết xuất cho tệp DWG và DXF.

Mẹo: Để làm điều này, bạn có thể thay đổi tham số VisibilityMode trong tùy chọn rasterization.

Lưu ý: Kết xuất như hiển thị bởi AutoCAD hoặc như in bởi AutoCAD, hãy kiểm tra đoạn mã và các tệp đính kèm AsPrint.png và AsScreen.png

Ví dụ:

using CadImage cadImage = (CadImage)Image.Load(GetPath("file.dwg"));
// AsPrint
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor;
rasterizationOptions.PageHeight = 2000;
rasterizationOptions.PageWidth = 2000;
rasterizationOptions.VisibilityMode = VisibilityMode.AsPrint;
string outPath = InputOutputManager.GetFileInOutputFolder(fileName + "_asPrint.pdf");
PdfOptions pdfOptions = new PdfOptions { VectorRasterizationOptions = rasterizationOptions };
cadImage.Save(outPath, pdfOptions);
// AsScreen
CadRasterizationOptions rasterizationOptions1 = new CadRasterizationOptions();
rasterizationOptions1.DrawType = CadDrawTypeMode.UseObjectColor;
rasterizationOptions1.PageHeight = 2000;
rasterizationOptions1.PageWidth = 2000;
rasterizationOptions1.VisibilityMode = VisibilityMode.AsScreen;
PdfOptions pdfOptions1 = new PdfOptions { VectorRasterizationOptions = rasterizationOptions1 };
string outPath1 = InputOutputManager.GetFileInOutputFolder(fileName + "_asScreen.pdf");
cadImage.Save(outPath1, pdfOptions1);