Reputation: 4239
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 Document(pdf);
ImageData data = ImageDataFactory.create(imgfilepath);
Image img = new Image(data);
img.scaleToFit(imageWidth, imageHeight);
img.setFixedPosition(1, 0, 0);
document.add(img);
-Using same Image i have created PDF from acrobat.
Problem :
(1) When i print above 2 PDFs- 1 created using iText, 2- created using Acrobat - i see quality different in print.
When i check metadata of both the PDFs i come to know there is some difference in Color Space property of PDF.( i have checked meta data here : https://www.metadata2go.com)
ITEXT PDF METADATA DETAIL:
Acrobat PDF METADATA DETAIL
So My Questions
(1) How can i get same quality like Acrobat using iText when print in CMYK Machine (ex.indigo)?
(2) Is There any Way to attach color profile(Color Space) to image in PDF? (currently what i have tried looks not working)
You can check both PDFs Here:
(1) PDF Created Using Acrobat
(2) PDF Created Using iText
Here some more information from iText RUPS:
iText Generated PDF Details
Upvotes: 1
Views: 2060
Reputation: 660
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();
}
Upvotes: 0