You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Mikhail Semionenko (JIRA)" <ji...@apache.org> on 2017/06/13 07:43:00 UTC

[jira] [Comment Edited] (PDFBOX-3823) Question about forming a PDF document, including CMYK images for printing.

    [ https://issues.apache.org/jira/browse/PDFBOX-3823?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16047464#comment-16047464 ] 

Mikhail Semionenko edited comment on PDFBOX-3823 at 6/13/17 7:42 AM:
---------------------------------------------------------------------

Thanks for answers. I'm interested in any opportunities to write images in PDF with using a color profile. I found how to write CMYK jpg (from file) to PDF (thanks for that). 

I try use JPEGFactory.createFromByteArray, but see exception.

My code:
BufferedImage rgbImage = ImageIO.read(file);
//rgbImage: BufferedImage@61a485d2: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@39fb3ab6 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1500 height = 2000 #numDataElements 3 dataOff[0] = 2
				
ColorSpace cpace = new ICC_ColorSpace(ICC_Profile.getInstance(Converter.class.getClassLoader().getResourceAsStream("CoatedFOGRA27.icc")));
ColorConvertOp op = new ColorConvertOp(rgbImage.getColorModel().getColorSpace(), cpace, null);       

BufferedImage cmykImage = op.filter(rgbImage, null);
//cmykImage: BufferedImage@6276ae34: type = 0 ColorModel: #pixelBits = 32 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@7946e1f4 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1500 height = 2000 #numDataElements 4 dataOff[0] = 0
	    
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(cmykImage, "jpg", baos); //javax.imageio.IIOException: Invalid argument to native writeImage
byte[] cmykImageBytes = baos.toByteArray();

PDImageXObject img = JPEGFactory.createFromByteArray(doc, cmykImageBytes);

I'm not sure. Maybe I made a mistake. 


was (Author: semionenko):
Thanks for answers. I'm interested in any opportunities to write images in PDF with using a color profile. I found how to write CMYK jpg (from file) to PDF (thanks for that). But I didn't find the opportunity to convert RGB jpg to CMYK jpg (with use icc) or to write RGB jpg to PDF as a CMYK image.

I try use JPEGFactory.createFromByteArray, but see exception.

My code:
BufferedImage rgbImage = ImageIO.read(file);
//rgbImage: BufferedImage@61a485d2: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@39fb3ab6 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1500 height = 2000 #numDataElements 3 dataOff[0] = 2
				
ColorSpace cpace = new ICC_ColorSpace(ICC_Profile.getInstance(Converter.class.getClassLoader().getResourceAsStream("CoatedFOGRA27.icc")));
ColorConvertOp op = new ColorConvertOp(rgbImage.getColorModel().getColorSpace(), cpace, null);       

BufferedImage cmykImage = op.filter(rgbImage, null);
//cmykImage: BufferedImage@6276ae34: type = 0 ColorModel: #pixelBits = 32 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@7946e1f4 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1500 height = 2000 #numDataElements 4 dataOff[0] = 0
	    
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(cmykImage, "jpg", baos); //javax.imageio.IIOException: Invalid argument to native writeImage
byte[] cmykImageBytes = baos.toByteArray();

PDImageXObject img = JPEGFactory.createFromByteArray(doc, cmykImageBytes);

I'm not sure. Maybe I made a mistake. 

> Question about forming a PDF document, including CMYK images for printing.
> --------------------------------------------------------------------------
>
>                 Key: PDFBOX-3823
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3823
>             Project: PDFBox
>          Issue Type: Task
>          Components: PDModel
>    Affects Versions: 2.0.6
>            Reporter: Mikhail Semionenko
>            Assignee: Tilman Hausherr
>            Priority: Minor
>              Labels: CMYK
>             Fix For: 2.0.7, 3.0.0
>
>         Attachments: Screen Shot 2017-06-09 at 11.37.22.png
>
>
> It is necessary to form a PDF document, which in the future will be sent to print the company's printers. There are several ICC files provided by companies for printing.
> I have RGB images that should be in CMYK after adding to PDF.
> My code is now for drawing an image:
> ImageObject = LosslessFactory.createFromImage (document, image);
> ContentStream.drawImage (imageObject, position.x, position.y, imageSize.width, imageSize.height);
> I'm wondering whether it is possible to display images in a document in ColorSpace CMYK? Unfortunately, I'm not find working examples yet.
> If so, how can I get PDImageXObject in CMYK ColorSpace from BufferedImage in RGB ColorSpace?
> When I try to create PDImageXObject instance from CMYK image file I get exception:
> javax.imageio.IIOException: Unsupported Image Type



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org