使用 jobconverter 将 pdf 转换为 pdf/a 时出现问题

问题描述 投票:0回答:1

尝试使用 http://kapion.ru/convert-to-pdfa-with-jodconverter/ 指南将 pdf 转换为 pdf/a。

执行后得到编码的pdf文件。看起来像:

%PDF-1.5
%µµµµ
1 0 obj
<</Type/Catalog/Pages 2 0 R/Lang(de-CH) /StructTreeRoot 17 0 R/MarkInfo<</Marked 
true>>>>
endobj
2 0 obj

代码:

@Test
public void a() throws OfficeException {
    OfficeManager officeManager = LocalOfficeManager.make();
    DocumentConverter converter = LocalConverter.make(officeManager);
    try {
        officeManager.start();
        File inputFile = new File("C:/Users/user/Desktop/9.pdf");
        File pdfFile = new File("C:/Users/user/Desktop/Output/9.pdf");
        DocumentFormat pdfFormat = getDocumentFormatPDFA();
        converter.convert(inputFile).to(pdfFile).as(pdfFormat).execute();
    } catch (OfficeException e) {
        e.printStackTrace();
    } finally {
        if (officeManager.isRunning())
            officeManager.stop();
    }
}

private static DocumentFormat getDocumentFormatPDFA() {
    // PDF/A version
    final int PDFX1A2001 = 1;
    final Map<String, Integer> pdfOptions = new HashMap<>();
    pdfOptions.put("SelectPdfVersion", PDFX1A2001);
    return DocumentFormat.builder()
            .inputFamily(DocumentFamily.TEXT)
            .name("PDF/A")
            .extension("pdf")
            .mediaType("pdf")
            .storeProperty(DocumentFamily.TEXT, "FilterData", pdfOptions)
            .storeProperty(DocumentFamily.TEXT, "FilterName", "writer_pdf_Export")
            .unmodifiable(false)
            .build();
}

请你帮我一下好吗?

java pdf converters pdfa
1个回答
1
投票

OpenOffice 不支持 pdf 阅读。如何使用外部库将 pdf 转换为 docx\html,然后使用 OpenOffice 将其转换为 pdf/a。

© www.soinside.com 2019 - 2024. All rights reserved.