DWF 도면
Contents
[
Hide
]DWF 도면을 PDF로 내보내기
Aspose.CAD for Java API는 DWF 형식의 AutoCAD 도면을 로드하고 이를 PDF로 변환할 수 있습니다. 이 주제에서는 DWF를 PDF 형식으로 변환하는 Aspose.CAD API의 사용법을 간단한 단계로 설명합니다.
DWF 파일을 PDF로 변환하기
DWF를 PDF로 변환하기 위해 필요한 간단한 단계는 다음과 같습니다.
- Image 인스턴스로 DWF 파일을 로드합니다.
- CadRasterizationOptions 클래스의 객체를 생성하고 PageHeight 및 PageWidth 속성을 설정합니다.
- PdfOptions 클래스의 객체를 생성하고 VectorRasterizationOptions 속성을 설정합니다.
- Image.save를 호출하면서 PdfOptions 객체를 두 번째 매개변수로 전달합니다.
아래의 코드 샘플은 DWF 도면을 PDF로 내보내는 방법을 보여줍니다.
This file contains hidden or 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 fileName = (dataDir +"site.dwf"); | |
com.aspose.cad.Image image = com.aspose.cad.Image.load(fileName); | |
{ | |
PdfOptions pdfOptions = new PdfOptions(); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
rasterizationOptions.setPageHeight(500); | |
rasterizationOptions.setPageWidth(500); | |
rasterizationOptions.setLayouts(new String[] { "Model" }); | |
// export | |
String outPath = dataDir + "site.pdf"; | |
image.save(outPath, pdfOptions); | |
} | |
DWF의 레이어 지원
Aspose.CAD는 AutoCAD DWF 도면 엔터티를 로드하고 이를 전체 도면으로 JPG 형식으로 렌더링하는 기능을 제공합니다.
- Image.load 팩토리 메서드를 사용하여 DWF 도면 파일을 로드합니다.
- CadRasterizationOptions 클래스의 객체를 생성합니다.
- 원하는 레이어를 추가합니다.
- Image.save를 호출하면서 두 번째 매개변수로 JPEGOptions 객체를 전달합니다.
아래의 코드 샘플은 기본 설정을 사용하여 파일을 변환하는 방법을 보여줍니다.
This file contains hidden or 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
// The path to the resource directory. | |
String dataDir = Utils.getDataDir(SupportOfLayers.class) + "DWFDrawings/"; | |
String srcFile = dataDir + "for_layers_test.dwf"; | |
String outFile = dataDir + "for_layers_test.jpg"; | |
Image image = Image.load(srcFile); | |
/// Create an instance of CadRasterizationOptions and set its various properties | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Add desired layers | |
List<String> stringList = new ArrayList<>(Arrays.asList("LayerA")); | |
rasterizationOptions.setLayers(stringList); | |
JpegOptions jpegOptions = new JpegOptions(); | |
jpegOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export the DXF to JPG | |
image.save(outFile, jpegOptions); |