How to change pdf font color
How to change pdf font color
Hi all,
Please advise how to use 'convert' to change font colour on a PDF file?
Thanks
Regards
satimis
Please advise how to use 'convert' to change font colour on a PDF file?
Thanks
Regards
satimis
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to change pdf font color
Please always provide your IM version and platform/OS.
Note that ImageMagick will rasterize your PDF, process the raster image, then put a vector shell around the rasterized image. It will not preserve any vector graphics in your PDF.
See http://www.imagemagick.org/Usage/formats/#vector
If you still want to proceed, then post a link to one of your PDF files. You can post to any free hosting service and put your URL here so we can download your file.
Note that ImageMagick will rasterize your PDF, process the raster image, then put a vector shell around the rasterized image. It will not preserve any vector graphics in your PDF.
See http://www.imagemagick.org/Usage/formats/#vector
If you still want to proceed, then post a link to one of your PDF files. You can post to any free hosting service and put your URL here so we can download your file.
Re: How to change pdf font color
Hi fmw42,
Thanks for your advice.
OS - Ubuntu 16.04
Imagemagick
⟫ apt-cache policy imagemagick
PDF File
https://www.dropbox.com/s/veyywew9dfshb ... d.pdf?dl=0
Regards
satimis
Thanks for your advice.
OS - Ubuntu 16.04
Imagemagick
⟫ apt-cache policy imagemagick
Code: Select all
imagemagick:
Installed: 8:6.8.9.9-7ubuntu5.3
Candidate: 8:6.8.9.9-7ubuntu5.3
Version table:
*** 8:6.8.9.9-7ubuntu5.3 100
100 /var/lib/dpkg/status
8:6.8.9.9-7 500
500 http://ubuntu.01link.hk xenial/main amd64 Packages
https://www.dropbox.com/s/veyywew9dfshb ... d.pdf?dl=0
Regards
satimis
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to change pdf font color
try this:
Code: Select all
convert -density 300 method.pdf -fuzz 10% -fill red -opaque black result.pdf
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to change pdf font color
An alternate and possibly better method is
Code: Select all
convert -density 300 method.pdf -alpha copy -background red -flatten result.pdf
Re: How to change pdf font color
Your advice works here. Thanksfmw42 wrote: ↑2017-06-19T15:33:35-07:00 An alternate and possibly better method is
Code: Select all
convert -density 300 method.pdf -alpha copy -background red -flatten result.pdf
Before posting I tried following command but failed;
Code: Select all
convert method.pdf -fuzz XX% -fill red -opaque white result.pdf
Edit:
Following command works seamlessly to change background color;
Code: Select all
$ convert method.pdf -background "#ffd9cf" -flatten result.pdf
Regards
satimis
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to change pdf font color
Yes, hex colors are permitted. On unix systems, they need to enclosed in quotes as you have done.
See the following for the forms of colors that IM can handle: http://www.imagemagick.org/script/color.php
See the following for the forms of colors that IM can handle: http://www.imagemagick.org/script/color.php
Re: How to change pdf font color
Following command works for me. Thanksfmw42 wrote: ↑2017-06-19T18:11:27-07:00 Yes, hex colors are permitted. On unix systems, they need to enclosed in quotes as you have done.
See the following for the forms of colors that IM can handle: http://www.imagemagick.org/script/color.php
Code: Select all
convert -density 300 method.pdf -alpha copy -background '#1cb7fb' -flatten result.pdf
1) Changing ONLY WhatsApp on the file to red and other text remaining in black?
2) Adding the word 'public' in red before Wi-Fi connection?
With pdftk
1) I can merge certain pages from within multiple .pdf files into one new document.
2) set locking password to .pdf file
etc.
Can I do those with ImageMagick convert?
Thanks
Regards
satimis
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to change pdf font color
1) You would have to create a black/white mask to use to select where you wanted to change to red and where to leave as black. See http://www.imagemagick.org/Usage/compose/#composesatimis wrote:
Is it possible to do follows;
1) Changing ONLY WhatsApp on the file to red and other text remaining in black?
2) Adding the word 'public' in red before Wi-Fi connection?
2) You can use -draw or -annotate to add new text. See http://www.imagemagick.org/Usage/text/#draw and http://www.imagemagick.org/Usage/text/#annotate
1) Yes you can combine pages from one PDF with another PDF, but you have to rasterize both PDFs to the same density and then enclose that rasterized image in a vector PDF shell. So the text is no longer vector text and cannot be edited in a PDF editor.satimis wrote: With pdftk
1) I can merge certain pages from within multiple .pdf files into one new document.
2) set locking password to .pdf file
etc.
Can I do those with ImageMagick convert?
2) ImageMagick does not have any controls that I know about for locking or unlocking PDF files.
Re: How to change pdf font color
Your advice noted and thanksfmw42 wrote: ↑2017-06-19T20:58:27-07:00 - snip -
1) Yes you can combine pages from one PDF with another PDF, but you have to rasterize both PDFs to the same density and then enclose that rasterized image in a vector PDF shell. So the text is no longer vector text and cannot be edited in a PDF editor.
2) ImageMagick does not have any controls that I know about for locking or unlocking PDF files.
Having tried to convert the background of a .pdf file to transparent but failed;
1)
convert image.pdf -background '#00000000' -flatten result.pdf
2)
convert image.pdf -background transparent -flatten result.pdf
3
convert image.pdf image.png
convert image.png -background transparent -flatten result.png
all failed.
Regards
satimis
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to change pdf font color
try this:
Code: Select all
convert -density 300 method.pdf -alpha off -transparent white result.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to change pdf font color
Your method.pdf is already transparent. But not all viewers will show the background transparency. In ImageMagick on Unix, try
Code: Select all
display method.pdf
Re: How to change pdf font color
Tried;fmw42 wrote: ↑2017-06-19T21:29:46-07:00 try this:
Code: Select all
convert -density 300 method.pdf -alpha off -transparent white result.png
⟫ convert -density 300 image.pdf -alpha off -transparent white image_transp.png
⟫ display image_transp.png
It works. Thanks
Image .pdf
https://www.dropbox.com/s/ygu65v1z2o7gf ... 1.pdf?dl=0
Why we need "-desity 300" up?
Edit:
⟫ convert -density 300 image.pdf -alpha off -transparent white image_transp.pdf
⟫ display image_transp.pdf
also works
satimis
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to change pdf font color
PDF files are vector files. They have no size. You can expand the window they are in and the image expands. When you convert to a raster image, you need to tell the PDF what density to use. The larger the density, the bigger the dimensions of the resulting raster image. Pick a density that makes your results readable.
Re: How to change pdf font color
Hi,fmw42 wrote: ↑2017-06-19T20:58:27-07:001) You would have to create a black/white mask to use to select where you wanted to change to red and where to leave as black. See http://www.imagemagick.org/Usage/compose/#composesatimis wrote:
Is it possible to do follows;
1) Changing ONLY WhatsApp on the file to red and other text remaining in black?
2) Adding the word 'public' in red before Wi-Fi connection?
2) You can use -draw or -annotate to add new text. See http://www.imagemagick.org/Usage/text/#draw and http://www.imagemagick.org/Usage/text/#annotate
Could you please explain in more detail.
1)
What I expect to achieve is the complete text in method.pdf remain untouched,i.e. in black colour. Only the word WhatsApp changes to red color.
2)
Only add a word 'public' in red color before Wi-Fi and the complete text of method.pdf remains untouched, i.e. in black color,
Regards
satimis