Hi,
Marcel Stör schrieb:
On 08.04.2010, at 23:25, Marcel Stör wrote:
I had my first encounter with PDFBox today...I'm looking into ways to replace a
given color in a PDF. I've got some 80 PDFs in which one would like to replace
a blueish color with redish (adjust to customer's CI).
Google turned up PDFBox ConvertColorspace. So I tried.
java -cp commons-logging-1.1.1.jar:pdfbox-1.1.0.jar:log4j-1.2.15.jar
org.apache.pdfbox.ConvertColorspace -equiv "CMYK:(80,60,0,0)=CMYK:(0,99,100,0)"
fr_sample.pdf new_fr_sample.pdf
-> see attached fr_sample.pdf
The completion finished without error but the result is not what I expected. All kinds of
colors were replaced instead of just the "blue bars". Is PDFBox not capable of
doing what I want it to do or is there a problem with fr_sample.pdf?
Could the fact that I didn't get a reply here mean that PDFBox may be the wrong tool for what I try to accomplish?
AFAIU the ConvertColorspace command line tool is only able to convert a
RGB colorspace into a CMYK colorspace.
What other PDF manipulation library would be better suited to replace colors?
I don't know any other tool, but that doesn't mean that there isn't any.
I have a look at your document and it seems that the cs you try to replace is an
ICC-based cs. So it isn't that easy to adress it with just 4 CMYK values.
Theoretically it should be possible to replace the used cs with PDFBox:
- load the pdf using PDDocument.load
- search for the used cs (in your case it seems to be named as Cs6)
- replace the cs
- save the pdf
If you really like to implement such a program, you should have a look at the
PDFDebugger which comes with PDFBox. You can use it to visualize the content
of your pdf in a much more understandable way. The cs you are looking for can
be found in the resources dictionary of the page.
BR
Andreas Lehmkühler