PDFBox - 在转换为 PDF/A 期间包含多个颜色配置文件

PDFBox - include multiple color profiles during conversion to PDF/A

我们目前正在尝试合并多个 PDF 并从中创建一个 PDF/A (1B)。

目前我们在修复颜色配置文件时遇到了一个问题。我们收到的 PDF 没有嵌入颜色配置文件,因此在 PDFBox 的合并功能期间,不会合并任何 OutputIntents。所以在最后一步我们尝试添加颜色配置文件。

如果我们不添加任何颜色配置文件,我们会遇到 RGB 和 CMYK 的验证问题。如果我们将两个颜色配置文件添加到 PDDocumentCatalog,那么只有第一个的验证问题消失了。因此,如果我们先添加 RGB,我们只会遇到 CMYK 验证问题,反之亦然。

这是我们添加颜色配置文件时的部分代码:

      public void convertToPDFA(PDDocument doc, String file){

              PDMetadata metadata = new PDMetadata(doc);
              PDDocumentCatalog cat = doc.getDocumentCatalog();
              cat.setMetadata(metadata);

              // do metadata stuff, just removed it for now

              InputStream colorProfile = PDFService.class.getResourceAsStream("/pdfa/sRGB Color Space Profile.icm");
              PDOutputIntent oi = new PDOutputIntent(doc, colorProfile);
              oi.setInfo("sRGB IEC61966-2.1");
              oi.setOutputCondition("sRGB IEC61966-2.1");
              oi.setOutputConditionIdentifier("sRGB IEC61966-2.1");
              oi.setRegistryName("http://www.color.org");
              cat.addOutputIntent(oi); 

这是RGB的代码,我们还为CMYK添加了另一个*.icm颜色配置文件。 所以颜色配置文件似乎没问题,因为依赖于我们首先添加的那个,验证问题就消失了。

对我来说,感觉我们只是遗漏了一件小事,即两种颜色配置文件都将被接受,或者只能使用一种颜色配置文件来创建 PDF/A?

在此先致谢并致以亲切的问候

只允许一个输出意图,参见here。那里还提到了另一种选择,即仅使用基于 ICC 的色彩空间。

应该可以(尽管超出了问题的范围)将 ICC 配置文件分配给 /DeviceGray、/DeviceRGB 或 /DeviceCMYK,方法是在资源中的 ColorSpaces 添加 DefaultGray、DefaultRGB 或 DefaultCMYK 条目字典,如 the PDF specification:

第 8.6.5.6 节所述

When a device colour space is selected, the ColorSpace subdictionary of the current resource dictionary (see 7.8.3, "Resource Dictionaries") is checked for the presence of an entry designating a corresponding default colour space (DefaultGray, DefaultRGB, or DefaultCMYK, corresponding to DeviceGray, DeviceRGB, or DeviceCMYK, respectively). If such an entry is present, its value shall be used as the colour space for the operation currently being performed.

请注意,使 PDF 文件符合 PDF/A-1b 通常比仅添加输出意图更棘手 - 使用 PDFBox preflight or with the online validator from PDF Tools 检查您的文件,有很多可能的错误。这就是为什么有来自 Callas Software 或 PDF Tools 的产品可以将 PDF 文件转换为 PDF/A.