java类库文档_PDF文档的Java类库

java类库文档

Big Faceless PDF库的2.11.10版现已发布。

Big Faceless PDF是一个Java类库,用于创建,编辑,显示和打印PDF文档。 它可以读写高达1.7版(Acrobat 8​​.0)的PDF。

在此版本中,渲染引擎已进行了重写,并且添加了OpenTypeFont构造函数,用于创建OpenTypeFont的完整副本,而无需首先从源中重新加载它。 加载PDF / E文档的问题已得到解决,此外还修复了其他一些错误。 请参阅发行说明以获取更多信息。

标准版的许可证起价为$ 850.00。


翻译自: https://jaxenter.com/java-class-library-for-pdf-documents-101279.html

java类库文档

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
常用的Java类库包括Apache POI和iTextPDF。Apache POI可以读取和写入Microsoft Office文件,而iTextPDF可以创建PDF文件。可以使用这两个库将Office文件转换为PDF格式。 以下是使用这两个库将Word文档转换为PDF的示例代码: ```java import java.io.*; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.converter.pdf.PdfConverter; import org.apache.poi.xwpf.converter.pdf.PdfOptions; public class WordToPdfConverter { public static void main(String[] args) { try { FileInputStream in = new FileInputStream(new File("input.docx")); XWPFDocument document = new XWPFDocument(in); PdfOptions options = PdfOptions.create(); OutputStream out = new FileOutputStream(new File("output.pdf")); PdfConverter.getInstance().convert(document, out, options); System.out.println("Word document converted to PDF successfully"); out.close(); } catch (Exception e) { e.printStackTrace(); } } } ``` 使用iTextPDF将Excel文档转换为PDF的示例代码如下: ```java import java.io.*; import com.itextpdf.text.Document; import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.PdfImportedPage; import com.itextpdf.text.pdf.PdfReader; import com.itextpdf.text.PageSize; public class ExcelToPdfConverter { public static void main(String[] args) { try { FileInputStream in = new FileInputStream(new File("input.xlsx")); Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File("output.pdf"))); document.open(); PdfImportedPage page; PdfReader reader = new PdfReader(in); int totalPages = reader.getNumberOfPages(); for (int i = 1; i <= totalPages; i++) { page = writer.getImportedPage(reader, i); document.newPage(); writer.getDirectContent().addTemplate(page, 0, 0); } document.close(); System.out.println("Excel document converted to PDF successfully"); } catch (Exception e) { e.printStackTrace(); } } } ``` 请注意,这些代码仅适用于将Microsoft Office文件转换为PDF格式。如果您需要将其他格式的文件转换为PDF,您可能需要使用其他库或工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值