Apache PDFBox
- 主要功能:创建、提取文本,分割 / 合并 / 删除 …
- 主要类:
- PDDocument PDF文档对象
- PDFTextStripper PDF文本对象
- PDFMergerUtility 合并工具
写入PDF文件
public static void main(String[] args) {
createPDFFile();
}
@SuppressWarnings("all")
public static void createPDFFile() {
PDDocument doc = null;
PDPage page = null;
try {
doc = new PDDocument();
page = new PDPage(PDRectangle.A4);
PDFont font = PDType0Font.load(doc, new File("D:\\PingFang Bold.ttf"));
PDPageContentStream content = new PDPageContentStream(doc, page);
page.getResources().add(font);
doc.addPage(page