使用 jobconverter 从 pdf 转换为 pdf/a 的问题

Troubles with convertation from pdf to pdf/a using jobconverter

正在尝试使用 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();
}

你能帮我解决一下吗?

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