package com.aspose.cad.examples.DXFDrawings;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;
import com.aspose.cad.Color;
import com.aspose.cad.Image;
import com.aspose.cad.SizeF;
import com.aspose.cad.examples.Utils.Utils;
import com.aspose.cad.fileformats.cad.CadImage;
import com.aspose.cad.fileformats.cad.cadconsts.CadEntityTypeName;
import com.aspose.cad.fileformats.cad.cadobjects.CadBaseEntity;
import com.aspose.cad.fileformats.cad.cadobjects.CadRasterImage;
import com.aspose.cad.fileformats.cad.cadobjects.CadText;
import com.aspose.cad.imageoptions.CadRasterizationOptions;
import com.aspose.cad.imageoptions.PdfOptions;
import com.aspose.cad.imageoptions.PenOptions;
import com.aspose.cad.imageoptions.UnitType;
import com.aspose.cad.internal.Exceptions.Exception;
import com.aspose.cad.internal.imaging.LineCap;
public class ExportDXFDrawingToPdfTEXT {
public static void main(String[] args) {
try {
System.out.println("start time:" + new Date());
// The path to the resource directory.
String filename = "TesringFile";// ""1 3076 5400 0502";
String dataDir = "C:/Users/admin/Desktop/testing Drg autocad pdf/";
// ExStart:ExportDXFDrawingToPDF
String srcFile = dataDir + filename + ".dxf";
Image image = Image.load(srcFile);
// Create an instance of CadRasterizationOptions and set its various
// properties
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setUnitType(UnitType.Millimeter);
rasterizationOptions.setBackgroundColor(Color.getWhite());
rasterizationOptions.setPageWidth(297);
rasterizationOptions.setPageHeight(210);
// rasterizationOptions.setAutomaticLayoutsScaling(false);
rasterizationOptions.setLayouts(new String[] { "Model" });
rasterizationOptions.setPageSize(new SizeF(297, 210));
CadImage cadImage = (CadImage) image;
// Create an instance of PdfOptions
PdfOptions pdfOptions = new PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
// Export the DXF to PDF
image.save(dataDir + filename + ".pdf", pdfOptions);
// ExEnd:ExportDXFDrawingToPDF
System.out.println("end time:" + new Date());
} catch (Exception e) {
e.printStackTrace();
}
}
}
// We have attached 3 files for your reference,
- AutoCad output in PDF
- Output from aspose-cad-20.11-jdk16.jar
- Output from aspose-cad-19.9-jdk16.jar
1)Outputfrom AutoCad.pdf (87.5 KB)
2)Output from aspose-cad-20.11-jdk16.pdf (66.2 KB)
3)Output from aspose-cad-19.9-jdk16.pdf (65.0 KB)