I am using iText-7 java library to generate pdf using below code. (I am adding image to pdf doc)
pdf = new PdfDocument(writer);
Document document = new Docume
It seems that if the image is manipulated, the ICC profile is lost.
I used the PdfCanvas api to add an image taken from iPhone to the PDF, it looks good to me.
@Test
public void testImageColorSpace() throws Exception {
String imageWithIcc = resourceFile("image-ios-profile.jpg");
String destination = targetFile("image-colorspace-itext-pdfcanvas.pdf");
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destination));
PdfPage page = pdfDocument.addNewPage(new PageSize(mm2pt(400f), mm2pt(400f)));
PdfCanvas pdfCanvas = new PdfCanvas(page);
ImageData imageData = ImageDataFactory.create(imageWithIcc);
AffineTransform at = AffineTransform.getTranslateInstance(mm2pt(100f), mm2pt(100f));
at.concatenate(AffineTransform.getScaleInstance(mm2pt(200f), mm2pt(200f)));
float[] matrix = new float[6];
at.getMatrix(matrix);
pdfCanvas.addImage(imageData, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
pdfDocument.close();
}