如何用pdfbox添加一个cmyk的图片

如果你不知道怎么获得一个cmyk的img,可以参考 《Java如何将RGB图片转化为CMYK图片》 

PDPage page = new PDPage(REC_B5_BLEED);
page.setMediaBox(REC_B5_BLEED);

// img必须是cmyk的
PDImageXObject pdImage = LosslessFactory.createFromImage(document, img);
pdImage.setColorSpace(PDColorSpace.create(COSName.DEVICECMYK));

PDPageContentStream contentStream = new PDPageContentStream(document, page);
contentStream.drawImage(pdImage, x, y, width, height);
contentStream.close();

document.addPage(page);

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *