• 背景 :
我们正在开发 AFP 到 PDF 工具。它涉及将 AFP(高级功能处理)文件转换为 PDF。
• 详细的问题陈述:
我们有嵌入 TIFF 图像的 AFP 文件。图像对象在功能集 45 中进行了描述,有点像这样 -
Image Content Begin Tile Image Encoding Parameter – TIFF LZW Begin Transparency Mask Image Encoding Parameter – G4MMR Image Data Elements End Transparency Mask Image Data Elements (IDE Size 32) – 4 bands: CMYK End Tile End Image Content
我们想使用 Java /iText API 将此平铺图像写入 PDF。到目前为止,我们可以编写 G4MMR 图像。但是,我们无法将 CMYK 色带数据(蓝色)应用于此图像。
• 尝试的解决方案:
编写 G4MMR 图像的代码如下:
此处给出了 saveAsTIFF 方法 – http://www.jpedal.org/PDFblog/2011/08/ccitt-encoding-in-pdf-files-converting-pdf-ccitt-data-into-a-tiff/ 如前所述,我们无法将 CMYK 4 波段图像颜色数据应用于此 G4MMR 图像。ByteArrayOutputStream decode = saveAsTIFF(<width>,<height>,<imageByteData>); RandomAccessFileOrArray ra=new RandomAccessFileOrArray(saveAsTIFF.toByteArray()); int pages = TiffImage.getNumberOfPages(ra); for(int i1 = 1; i1 <= pages; i1++){ img1 = TiffImage.getTiffImage(ra, i1); } img1.scaleAbsolute(256, 75); document.add(img1);
• 每个组件版本的技术堆栈:
1. JDK 1.6
2. itextpdf-5.1
——乌梅什·帕塔克