pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From PDF Developer <pdf...@yahoo.com.INVALID>
Subject Re: Changing Separation Names
Date Fri, 21 Sep 2018 07:56:13 GMT
Tilman 

I agree that this “high level” approach is only valid for a subset of PDFs. For a real
solution one would have to examine all of contents in the file and process accordingly. 

Fortunately, I only have to process files where a Designer has added a named separation but
has either made a typo in the name or has used a local language variant. 

One of these days I might make things more robust but for the moment it suffices. 

Thanks again. 

PDFDev

Sent from a mobile device


> On 21 Sep 2018, at 07:28, Tilman Hausherr <THausherr@t-online.de> wrote:
> 
>> Am 21.09.2018 um 00:08 schrieb PDF Developer:
>>  Tilman,
>> Thanks that was a big help.
>> Here is a short Groovy Script the "before" and "after" appear to show that only the
appropriate Named Separations are modified.
>> 
>> String inFile = "e:/testPDFs/_VarnishDiecutCrease.pdf"
>> 
>> Path fileLocation = Paths.get(inFile);
>> List<String> SeparationList = ["VARNISH", "Crease"]
>> 
>> byte[] pdfHandle = Files.readAllBytes(fileLocation)
>> 
>> PDPage pdPage = getPDPage(pdfHandle, 0)
>> PDResources pdResources= getPageResources(pdPage)
>> 
>> COSDictionary pdResDict = pdResources.getCOSObject()
>> 
>> COSDictionary ColorSpace =  pdResDict.getItem(COSName.COLORSPACE)
>> 
>> ColorSpace.keySet().forEach({
> 
> This works but there's an easier way in 2.0, from the resources you can get the colorspace
names, and from the name you can get the colorspace.
> 
> But your general strategy works only on the first level (this is OK if you created these
images yourself). Colorspaces can also be in images, in the resources of form XObjects, tiling
patterns and smasks.
> 
> In theory they could also be in the form xobjects of widget annotations but I've never
seen this.
> 
> Tilman
> 
>>     PDColor color = pdPage.getResources().getColorSpace(it).getInitialColor()
>>     PDSeparation SeparationSpace = color.getColorSpace()
>>     if (SeparationList.contains(SeparationSpace.getColorantName())) {
>>         COSArray cs = SeparationSpace.getCOSObject()
>>         cs.set(1, COSName.getPDFName("XXXX"))
>>     }
>> } )
>> 
>> PDFDev
>> 
>>     On Thursday, September 20, 2018, 6:22:14 PM GMT+1, Tilman Hausherr <THausherr@t-online.de>
wrote:
>>    AFAIK the name isn't used, so you could do something like
>> 
>> sepCS.getCOSObject().set(1, COSName.getPDFName("TANZONE 12345 ABC"));
>> 
>> Tilman
>> 
>>> Am 20.09.2018 um 11:43 schrieb PDF Developer:
>>>   Hello,
>>> Does any one have sample code of how to change the name of separation in a PDF?
For example I have "VARNISH" and "LAK" separations in some of my PDFs and I'd like to change
them to, say, "Varnish".
>>> I was able to enumerate all of the Separations in my test PDF using code from
here. While that example also shows how to use a Spot/Separation Colour in a drawing operation,
I just need to rename the separation and then save the PDF with the modified colourspace.
I don't want, or need, to modify the (CMYK) values of the separation.
>>> Any ideas before I start digging around at the COS Level?
>>> Thanks in advance.
>>> 
>>> 
>>>     |
>>> |
>>> |
>>> |  |    |
>>> 
>>>     |
>>> 
>>>     |
>>> |
>>> |  |
>>> Does PDFBox Support Spot Colors and Separations?
>>>   I am interested in using PDFBox for a project that requires being able to specify
spot colors and color separati...  |  |
>>> 
>>>     |
>>> 
>>>     |
>>> 
>>>   
>> 
>> ---------------------------------------------------------------------
>> 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
> 


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


Mime
View raw message