Hello,
When we generate pdf from dxf appying Normalize export page size despite of unit type defined on drawing, then the line thickness and text thickness is more than given in actual drawing. line thickness and text thickness are normal if we do not scale the page size
Code for Output without applying pdf page size
String dataDir = Utils.getDataDir(ExportDXFDrawingToPDF.class) + "DXFDrawings/";
String srcFile = dataDir + filename + ".dxf";
Image image = Image.load(srcFile);
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setBackgroundColor(Color.getWhite());
CadImage cadImage = (CadImage) image;
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
image.save(dataDir + filename + ".pdf", pdfOptions);
Code for Output applying pdf page size
Reference: Image - Aspose.CAD for Java - API Reference
String filename = "WKT GA";
String dataDir = Utils.getDataDir(ExportDXFDrawingToPDF.class) + "DXFDrawings/";
String srcFile = dataDir + filename + ".dxf";
Image image = Image.load(srcFile);
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setBackgroundColor(Color.getWhite());
Boolean currentUnitIsMetric = false;
double currentUnitCoefficient = 1.0;
PageSize pageSize = new PageSize(cadImage.getUnitType());
currentUnitIsMetric = pageSize.getIsMetric();
currentUnitCoefficient = pageSize.getCoefficient();
if (currentUnitIsMetric) {
double metersCoeff = 1 / 1000.0;
double scaleFactor = metersCoeff / currentUnitCoefficient;
rasterizationOptions.setPageWidth((float) (297 * scaleFactor));
rasterizationOptions.setPageHeight((float) (210 * scaleFactor));
rasterizationOptions.setUnitType(UnitType.Millimeter);
} else {
rasterizationOptions.setPageWidth((float) (11.69f / currentUnitCoefficient));
rasterizationOptions.setPageHeight((float) (8.27f / currentUnitCoefficient));
rasterizationOptions.setUnitType(UnitType.Inch);
}
CadImage cadImage = (CadImage) image;
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
image.save(dataDir + filename + ".pdf", pdfOptions);
Could you please help how to keep text and line thickness same as per drawing when Normalize export page size
Issue.png (87.4 KB)
Output applying pdf page size.pdf (562.0 KB)
Output without applying pdf page size.pdf (536.3 KB)
WKT GA.zip (120.5 KB)