Thanks again, I am getting the hang of it.
Working with tokens (operators) is quite tedious.
In my case a non stroking color operator is not enough, the color name is just 
an entry in the color space. I need to define (create) the space too.

Is there a way (read sample source code) to mix working with PD content streams 
and low-level parser streams?
Like use high-level methods to create/copy a resource, get the change operators 
and insert them in another stream?

Thank you.

On 14 Aug 2020, at 15:03, Tilman Hausherr 
<thaush...@t-online.de<mailto:thaush...@t-online.de>> wrote:

Am 14.08.2020 um 13:05 schrieb Pop, Rares:
Thank you. I have identified the operator SetNonStrokingColorOperator but I 
think I am missing something.

I have a pdf of sample Spot colours. I am loading it and reading all the 
colours from the ColorSpace resources.

Then I must read an inputPDF (that has no spot colors - i.e. no resources in 
the color space).
I must simply apply a given spot color to all the elements within the inputPDF.
Then save it as outputPDF.

Is there an example that does anything remotely similar to that?


No... what you could do is about like this:

- open both PDFs

- get the spot color

- add it to the destination PDF

- remember the name (probably "cs1")

- replace the old color setting with the new in the content stream

- save

so maybe in the old PDF, you find "0 g" / "0 0 0 rg", then replace that with 
the appropriate colorspace selection and then color selection, e.g. "cs1 cs 0 
sc" . An example how to work with the content stream can be found in 
RemoveAllTexts.java in the source code download.

If there is nothing, then include the two commands mentioned at the beginning.

Tilman



I am happy to pay for consultancy here.

Best,
Ra



On 2020/08/14 10:46:56, Tilman Hausherr <t...@t-online.de<http://t-online.de>> 
wrote:
Am 14.08.2020 um 12:21 schrieb Pop, Rares:>
Hi guys,>
I am new to pdfbox and I am trying to modify the color of an existing text 
element.>
My current understanding is that I need to parse the stream, iterate through 
the tokens and find the one I need to change the color for.>
Then insert a Change Color Operator before it.>
Is this the correct way and could you please show me how to create a change 
colour operator?>

Yes, but it may be difficult to find the correct element. The best would >
be to have a look at that file with PDFDebugger, you can see all the >
operators there. When you hover the mouse over such a color operator it >
will show you the color.>

Tilman>


--------------------------------------------------------------------->
To unsubscribe, e-mail: 
users-unsubscr...@pdfbox.apache.org<mailto:users-unsubscr...@pdfbox.apache.org>>
For additional commands, e-mail: 
users-h...@pdfbox.apache.org<mailto:users-h...@pdfbox.apache.org>>

---------------------------------------------------------------------
To unsubscribe, e-mail: 
users-unsubscr...@pdfbox.apache.org<mailto:users-unsubscr...@pdfbox.apache.org>
For additional commands, e-mail: 
users-h...@pdfbox.apache.org<mailto:users-h...@pdfbox.apache.org>



---------------------------------------------------------------------
To unsubscribe, e-mail: 
users-unsubscr...@pdfbox.apache.org<mailto:users-unsubscr...@pdfbox.apache.org>
For additional commands, e-mail: 
users-h...@pdfbox.apache.org<mailto:users-h...@pdfbox.apache.org>

Reply via email to