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 
<[email protected]> 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: [email protected]
For additional commands, e-mail: [email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to