Specify render mode for DWG and DXF files
Contents
[
Hide
]How to specify render mode for DWG and DXF files
Issue: How to specify render mode for DWG and DXF files.
Tips: To do this, you can change the VisibilityMode parameter in the rasterization options.
Note: Render as displayed by AutoCAD or as printed by AutoCAD, check the snippet and attached files AsPrint.png and AsScreen.png
Example:
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
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); |