• Background :
We are developing AFP to PDF tool. It involves conversion of AFP (Advanced Function Processing) file to PDF.
• Detailed Problem statement :
We have AFP file with embedded TIFF Image. The image object is described in Function Set 45, represented somewhat like this -
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
We want to write this tiled image to PDF either using Java /iText API. As of now, we can write G4MMR image. But, we are not able to apply CMYK color band data (Blue Color) to this image.
• Solution tried :
The code to write G4MMR image goes as follows –
saveAsTIFF method is given here – http://www.jpedal.org/PDFblog/2011/08/ccitt-encoding-in-pdf-files-converting-pdf-ccitt-data-into-a-tiff/ As mentioned, we are not able to apply CMYK 4 band image color data to this G4MMR image.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);
• Technology stack with versions of each component :
1. JDK 1.6
2. itextpdf-5.1
-- Umesh Pathak