DGN AutoCAD 내보내기
PDF로 DGN AutoCAD 형식 내보내기
Aspose.CAD for .NET API는 DGN AutoCAD 파일을 로드하고 PDF 형식으로 변환하는 기능을 도입했습니다. CadImage 클래스가 그 목적을 수행합니다.
기존 DGN 파일을 CadImage로 로드해야 합니다. 다양한 속성을 설정하고 CadRasterizationOptions 클래스의 인스턴스를 생성합니다. PdfOptions 클래스의 인스턴스를 생성하고 CadRasterizationOptions 인스턴스를 전달합니다. 이제 CadImage 클래스 인스턴스의 Save 메서드를 호출합니다.
샘플 코드
다음은 DGN을 PDF 형식으로 변환/내보내기 위한 코드 시연입니다.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.Layouts = new[] { "Model" }; | |
PdfOptions pdfOptions = new PdfOptions(); | |
pdfOptions.VectorRasterizationOptions = rasterizationOptions; | |
cadImage.Save(MyDir + "conic_pyramid.pdf", pdfOptions); | |
} |
DGN AutoCAD 형식에서 래스터 이미지 형식으로 내보내기
Aspose.CAD for .NET API는 DGN AutoCAD 파일을 로드하고 래스터 이미지로 변환하는 기능을 도입했습니다. CadImage 클래스가 그 목적을 수행합니다.
기존 DGN 파일을 CadImage로 로드해야 합니다. 다양한 속성을 설정하고 CadRasterizationOptions 클래스의 인스턴스를 생성합니다. JpegOptions 클래스의 인스턴스를 생성하고 CadRasterizationOptions 인스턴스를 전달합니다. 이제 CadImage 클래스 인스턴스의 Save 메서드를 호출합니다.
샘플 코드
다음은 DGN을 JPEG 이미지로 변환/내보내기 위한 코드 시연입니다.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath)) | |
{ | |
// Create an object of DgnRasterizationOptions class and define/set different properties | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 600; | |
rasterizationOptions.PageHeight = 300; | |
rasterizationOptions.NoScaling = true; | |
rasterizationOptions.AutomaticLayoutsScaling = false; | |
// Create an object of JpegOptions class as we are converting the DGN to jpeg and assign DgnRasterizationOptions object to it. | |
Aspose.CAD.ImageOptionsBase options = new Aspose.CAD.ImageOptions.JpegOptions(); | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// Call the save method of the CadImage class object. | |
cadImage.Save(MyDir + "ExportDGNToRasterImage_out.pdf", options); | |
} |
DGN v7에 대한 3D 엔티티 지원
Aspose.CAD for .NET API는 DGN AutoCAD 파일을 로드하고 DGN v7에 대한 3D 엔티티를 지원하는 기능을 도입했습니다. CadImage 클래스가 그 목적을 수행합니다. 각 DGN 이미지에는 9개의 미리 정의된 뷰가 지원됩니다. 이는 1부터 9까지 열거됩니다. 내보내기 할 때 뷰가 정의되지 않으면 다중 페이지 출력 형식(예: PDF)의 경우 모든 뷰가 내보내지며 각 뷰는 별도의 페이지에 있습니다. DGN 파일 형식에서도 3D 엔티티가 지원되며 2D도 지원됩니다. 이를 위해, VectorRasterizationOptions를 사용하며, DGN 형식에서는 TypeOfEntities가 더 이상 사용되지 않습니다(2D와 3D가 동시에 지원됨).
샘플 코드
다음은 지원되는 DGN 요소를 확인하기 위한 샘플 코드입니다.
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_ExportingDGN(); | |
string sourceFilePath = MyDir + "Nikon_D90_Camera.dgn"; | |
string outFile = MyDir + "Nikon_D90_Camera.dgn"; | |
// Load an existing DGN file as CadImage. | |
using (DgnImage dgnImage = (DgnImage)Image.Load(sourceFilePath)) | |
{ | |
var options = new PdfOptions | |
{ | |
VectorRasterizationOptions = new CadRasterizationOptions | |
{ | |
PageWidth = 1500, | |
PageHeight = 1500, | |
AutomaticLayoutsScaling = true, | |
BackgroundColor = Color.Black, | |
Layouts = new string[] { "1", "2", "3", "9" }//only export 4 (1,2,3 and 9) views | |
} | |
}; | |
dgnImage.Save(outFile, options); | |
} |