【问题标题】:Troubles with convertation from pdf to pdf/a using jobconverter使用 jobconverter 从 pdf 转换为 pdf/a 的问题
【发布时间】:2021-11-17 04:42:31
【问题描述】:

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

你能帮我解决这个问题吗?

【问题讨论】:

  • @KJ 是的,我也尝试了第三个选项。关于错误 - 当我打开文件时 - 我看到 pdf 结构而不是必要的 pdf 文件。意思是:我有带有文本的 pdf 文件:bla bla -> 将其转换为 pdf/a -> 打开文件 -> 我看到 %PDF-1.5 %µµµµ 而不是 bla bla
  • @KJ 是的,尝试过 html -> pdf/a 运行良好。那么转换pdf-> pdf/a就麻烦了。试图更改电子表格、演示文稿、绘图上的 DocumentFamily.TEXT。没有帮助
  • @KJ import a source 是什么意思?我正在获取 pdf 文件作为输入

标签: java pdf converters pdfa


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2016-03-17
    • 2016-05-09
    • 2019-04-02
    • 1970-01-01
    • 2017-02-21
    • 2020-03-07
    • 1970-01-01
    • 1970-01-01
    • 2016-06-15
    相关资源
    最近更新 更多