Re: How to change pdf font color
Posted: 2017-06-20T10:12:43-07:00
1) Yes, this can be done, but requires you to manually draw a mask around the text you want changed. Here is an example:
Input PDF converted to a png at 72 dpi (you can change the dpi to a higher value if you want a larger image or higher resolution)
Manually draw a red box around the text you want to become red using some other tool such as Photoshop or GIMP, etc. The color is not important so long as it is not black or white.
Modify the mask to be white on black background
Composite the image, a red image and the mask together to make the final PNG image. You can replace PNG with PDF if you want.
2) ImageMagick is not a vector processor. So it cannot change vector text. Once rasterized, you can add text in any white area, but you cannot insert text between other words and change the location of any other text in an automatic manner. You could crop the text into words and recompose all the words in different locations, but this would be rather hard to do automatically.
Input PDF converted to a png at 72 dpi (you can change the dpi to a higher value if you want a larger image or higher resolution)
Code: Select all
convert -density 72 method.pdf tmp1.png
Manually draw a red box around the text you want to become red using some other tool such as Photoshop or GIMP, etc. The color is not important so long as it is not black or white.
Modify the mask to be white on black background
Code: Select all
convert tmp2.png -alpha off -fill black +opaque red -fill white -opaque red tmp3.png
Composite the image, a red image and the mask together to make the final PNG image. You can replace PNG with PDF if you want.
Code: Select all
convert tmp1.png \( -clone 0 -channel rgba -fill red -colorize 100 \) tmp3.png -compose over -composite method_mod.png
2) ImageMagick is not a vector processor. So it cannot change vector text. Once rasterized, you can add text in any white area, but you cannot insert text between other words and change the location of any other text in an automatic manner. You could crop the text into words and recompose all the words in different locations, but this would be rather hard to do automatically.