操作方法:
public synchronized File doCadToPdf(InputStream inputStream, String outputFilePath) throws IOException {
File outputFile = new File(outputFilePath);
LoadOptions opts = new LoadOptions();
opts.setSpecifiedEncoding(CodePages.SimpChinese);
opts.setCustomFontFolders(new String[]{fileProperties.getCustomFontFolder()});
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
cadRasterizationOptions.setBackgroundColor(Color.getWhite());
cadRasterizationOptions.setPageWidth(fileProperties.getNewImageHeight());
cadRasterizationOptions.setPageHeight(fileProperties.getNewImageWeight() + 105F);
cadRasterizationOptions.setAutomaticLayoutsScaling(true);
cadRasterizationOptions.setNoScaling(false);
cadRasterizationOptions.setDrawType(1);
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions);
try (Image cadImage = Image.load(inputStream, opts);
OutputStream stream = new FileOutputStream(outputFile)) {
cadImage.save(stream, pdfOptions);
return outputFile;
}
}
CAD 文件
efb0976e-a079-4e6f-b0bd-d695c73cf2c4.png (40.1 KB)
原文件
EZ15-85.001 H05_极片导板.zip (56.0 KB)
转换后
image.png (461.7 KB)
那些符号变成了字母