In my pdf file, i add images and text as below :
Image img = Image.getInstance(fileName); // type png or jpg
document.add(img);
Paragraph p = new Paragraph(...);
document.add(p);
I want to convert it to DeviceCMYK mode for printing. But in the book said : "iText doesn’t convert RGB colors into CMYK".
Then, how to solve this problem ? Must convert each img, text to CMYK color or covert all file pdf ?
I search in google and find some suggests : They use lib : Jmagic / JAI ...(ICC Color Profiles)
ICC Color Profiles : http://stackoverflow.com/questions/22298328/convert-rgb-png-to-cmyk-jpeg-using-icc-color-profiles
JAI : http://stackoverflow.com/questions/4472362/how-can-i-convert-an-rgb-image-to-cmyk-and-vice-versa-in-java
Do you have any suggestions ?
Update 1 :
My code is at below :
// PdfContentByte pdfCB = new PdfContentByte(writer);
// read buffer image (png or jpec) from link
BufferedImage rgbImage = ImageIO.read(new URL(imageLink));
BufferedImage cmykImage = null;
ColorSpace cpace = new ICC_ColorSpace(ICC_Profile.getInstance(this.class.getClassLoader()
.getResourceAsStream("OffsetEuroU360K85V25PO4.icc")));
ColorConvertOp op = new ColorConvertOp(rgbImage.getColorModel().getColorSpace(), cpace, null);
cmykImage = op.filter(rgbImage, null);
// write buffered image to local file
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(cmykImage, "jpg", baos);
baos.flush();
byte[] resultImageAsRawBytes = baos.toByteArray();
baos.close();
JAI.create("filestore", cmykImage, "/root/CMYK_IMAGE" + no + ".TIF", "TIFF");
// Add image to document
Image img = Image.getInstance(resultImageAsRawBytes);
// Image img = Image.getInstance(pdfCB, cmykImage, 1);
img.tagICC(com.itextpdf.text.pdf.ICC_Profile.getInstance(PBPMSItextExport.class.getClassLoader()
.getResourceAsStream("OffsetEuroU360K85V25PO4.icc")));
document.add(img);
Result error :
java.io.IOException: The byte array is not a recognized imageformat.
com.itextpdf.text.Image.getInstance(Image.java:442)
com.itextpdf.text.Image.getInstance(Image.java:348)
But image saved in local file is CMYK color.
How to instance image of iText with input is BufferedImage ?
Link of original img in RGB : http://www.mediafire.com/view/jlbc67q5gs2l3bj/00.png
Link of img is converted and saved to local : http://www.mediafire.com/view/a8lw5yhlcww9qbm/CMYK_IMAGE3.TIF