Spire.PDF for Java 12.1.4 现已正式发布。该版本新增了将 PDF 对比结果直接保存到文件流的功能。同时,针对 PDF 转换、渲染、打印及稳定性等多个方面的问题进行了修复,并进一步优化了部分功能的性能和布局效果。更多更新内容如下:
新功能:
- 支持将 PDF 对比结果保存到文件流。
// Create a new PdfDocument object 'pdf1' to work with the first PDF file
PdfDocument pdf1 = new PdfDocument();
// Load the first PDF file from the specified path
pdf1.loadFromFile("ComparePdfDocument_1.pdf");
// Create a new PdfDocument object 'pdf2' to work with the second PDF file
PdfDocument pdf2 = new PdfDocument();
// Load the second PDF file from the specified path
pdf2.loadFromFile("ComparePdfDocument_2.pdf");
// Create a PdfComparer object 'compare' with 'pdf1' and 'pdf2' as parameters for comparison
PdfComparer compare = new PdfComparer(pdf1, pdf2);
// Set the page ranges to be compared using the options of the comparer
compare.getOptions().setPageRanges(0, pdf1.getPages().getCount() - 1, 0, pdf2.getPages().getCount() - 1);
String result = "output.pdf";
File outFile = new File(result);
// Create an output stream to write the document to the output file
OutputStream outputStream = new FileOutputStream(outFile);
// Compare the PDF documents and save
compare.compare(outputStream);
// Dispose of system resources associated with 'pdf1'
pdf1.dispose();
// Dispose of system resources associated with 'pdf2'
pdf2.dispose();
问题修复与优化:
- 优化了 PDF 转图片的性能表现。
- 修复了 OFD 转 PDF 时可能出现内存溢出的问题。
- 改善了 PDF 转 Word 后在 WPS 中打开时的显示效果。
- 修复了打印 PDF 时背景色和部分字体效果不一致的问题。
- 优化了 PDF 转流式 Word 文档的布局效果。
- 修复了 PdfTrueTypeFont 在多线程环境下可能引发的异常问题。
- 修复了使用 “Yu Mincho” 字体生成内容不正确的问题。
- 修复了 PDF 转 PDF/A-1A 时文本错位的问题。
- 修复了表格内容提取结果中多出空格的问题。
- 修复了 PDF 转图片时公式丢失的问题。
- 修复了 PDF 转 HTML 时文本重叠的问题。
- 修复了加载 PDF 文档时抛出 “structure is not valid” 异常的问题。
- 修复了添加文本水印后保存文档时可能抛出 ArrayIndexOutOfBoundsException 异常的问题。
- 修复了 SVG 转 PDF 时内容不一致的问题。
- 修复了 OFD 转 PDF 过程中出现异常字符串解析错误的问题。
- 修复了 OFD 转 PDF 后内容不正确的问题。
获取 Spire.PDF for Java 12.1.4,请点击以下链接:







