Alireza Noori
Alireza Noori

Reputation: 15275

Change PDF Text color in C#

I'm looking for a way to programmatically change the text color of a PDF document. I have found several libraries but for now I have found a way to change the background color only. I would appreciate a sample code. Open Source libraries are preferred. Thanks.

Upvotes: 4

Views: 2370

Answers (1)

yms
yms

Reputation: 10418

If you can afford a commercial tool, Amyuni PDF Creator .Net allows you to do this by changing the TextColor and BackColor attributes of the desired Text object. This PDF edition library can modify the page content and it will draw the rectangle for you below the text. Usual disclaimer applies for this suggestion.

Another possibiity could be to generate bitmaps from your PDF file, using ImageMagic for example, then process each bitmap programmatically appling a color mapping (replacing each color channel by 255-value for example to obtain a color inversion), and then showing the resulting image or generating a new PDF from it. This approach has the disadvantage that the whole PDF will be converted to a raster image, and you will not be able to select text on it.

Upvotes: 1

Related Questions