小编Lip*_*ipu的帖子

如何使用pdfbox从pdf中提取粗体文本?

我正在使用Apache pdfbox来提取文本.我可以从pdf中提取文本,但我不知道如何知道这个词是否是粗体??? (代码建议会很好!!!)这是从pdf中提取纯文本的代码.

PDDocument document = PDDocument
    .load("/home/lipu/workspace/MRCPTester/test.pdf");
document.getClass();
if (document.isEncrypted()) {
    try {
        document.decrypt("");
    } catch (InvalidPasswordException e) {
        System.err.println("Error: Document is encrypted with a password.");
        System.exit(1);
    }
}

// PDFTextStripperByArea stripper = new PDFTextStripperByArea();
// stripper.setSortByPosition(true);
PDFTextStripper stripper = new PDFTextStripper();
stripper.setStartPage(1);
stripper.setEndPage(2);
stripper.setSortByPosition(true);
String st = stripper.getText(document);
Run Code Online (Sandbox Code Playgroud)

java pdf pdfbox

7
推荐指数
1
解决办法
6779
查看次数

标签 统计

java ×1

pdf ×1

pdfbox ×1