pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Max Rietmeijer | Add to Favorites <mrietmei...@addtofavorites.nl>
Subject Re: CMYK images
Date Fri, 24 Feb 2017 18:12:30 GMT
Some how my attachments show up bad in Apple Mail (and maybe other clients). On the iPhone
mailbox they seem to show up though.
Attached a zip for reference:



Max


> On 24 Feb 2017, at 19:05, Max Rietmeijer | Add to Favorites <mrietmeijer@addtofavorites.nl>
wrote:
>
> Worked like a charm. Great!
>
> <PastedGraphic-2.png>
>
> Needed the decode array. Without it the image turnes out very dark:
>
[cid:0f3a12f0-1b3d-4ada-9158-bd6aee0ae6f2@eurprd05.prod.outlook.com]
>
>
> We'll try to implement it in the solution.
>
> Thanks again.
>
> Max
>
>
>> On 24 Feb 2017, at 18:52, Max Rietmeijer | Add to Favorites <mrietmeijer@addtofavorites.nl>
wrote:
>>
>> Thanks for the effort. I'll give it a try!
>>
>> Max
>>
>>> On 24 Feb 2017, at 18:48, Tilman Hausherr <THausherr@t-online.de> wrote:
>>>
>>> Am 24.02.2017 um 10:28 schrieb Max Rietmeijer | Add to Favorites:
>>>> Hi Tilman,
>>>>
>>>> Thanx for the reaction. Our printing company depends in CMYK colors to make
offset prints. We create letters for clients who (of course) are very keen on company (logo)
colors printed in the right tones. These are always delivered to us in InDesign/Illustrator/...
using CMYK colors.
>>>>
>>>> Converting images to a specific format is no problem for us, but we need
a way of preserving CMYK colour information in the PDF. When exporting PDF's using InDesign
this information is preserved. How would we go about using PDFBox?
>>>>
>>>> We tried twelvemonkeys, but their JPG codec either converts CMYK to RGB or
creates an unusable image format.
>>>>
>>>> The attached image is a CMYK color based JPEG we should be able to include
as is.
>>>
>>> The image didn't get through, but then I remembered I could simply copy a JPEG
from a PDF from my collection. So here's some quick code, you need the twelvemonkeys library
for it:
>>>
>>>       try (PDDocument doc = new PDDocument())
>>>       {
>>>           PDPage page = new PDPage();
>>>           doc.addPage(page);
>>>           try (PDPageContentStream cs = new PDPageContentStream(doc, page))
>>>           {
>>>               // using Root/Pages/Kids/[1]/Resources/XObject/I2200006 from PDFBOX-2128-PORSCHE_CMYK
>>>               File f = new File("cmyk.jpg");
>>>
>>>               BufferedImage bim = ImageIO.read(f);
>>>
>>>               PDImageXObject img = new PDImageXObject(doc, new FileInputStream(f),
>>>                       COSName.DCT_DECODE, bim.getWidth(), bim.getHeight(),
>>>                       8, PDDeviceCMYK.INSTANCE);
>>>               COSArray decode = new COSArray();
>>>               decode.add(COSInteger.ONE);
>>>               decode.add(COSInteger.ZERO);
>>>               decode.add(COSInteger.ONE);
>>>               decode.add(COSInteger.ZERO);
>>>               decode.add(COSInteger.ONE);
>>>               decode.add(COSInteger.ZERO);
>>>               decode.add(COSInteger.ONE);
>>>               decode.add(COSInteger.ZERO);
>>>               img.setDecode(decode);
>>>
>>>               cs.drawImage(img, 0, page.getMediaBox().getHeight() - img.getHeight()/
4, img.getWidth() / 4, img.getHeight() / 4);
>>>           }
>>>           doc.save(new File("cmyk.pdf"));
>>>       }
>>>
>>> Note that this code will work ONLY for CMYK Jpeg files.
>>>
>>> The decode array was in the original PDF, I don't know if this is needed for
all CMYK files.
>>>
>>> Tilman
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>


Mime
View raw message