1

What I actually want to achieve is, the result I get when printing to pdf from Okular and clicking on force rasterization and print annotations. However, I would like to do this from the terminal (my ultimate goal is to create a dolphin service menu for this).

enter image description here

Bruni
  • 10,542

1 Answers1

1

convert seems to rasterize pdfs on the terminal. So convert -density 300 infile.pdf outfile.pdf would do the trick. Convert is provided by Imagemagick , so you would need to install that first. The file will be quite large but you can reduce its size with gostscript (e.g. gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=outfile.pdf infile.pdf or by trying some other answer from here)

A service menu for the rasterization would look like this:

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=application/pdf
Icon=acroread
Actions=rasterizepdf;

[Desktop Action rasterizepdf] Name=rasterize pdf Icon=acroread Exec=convert -density 300 %u "$(dirname "%u")/$(basename "%u" .pdf)_r.pdf"

Save it in ~/.local/share/kservices5/ServiceMenus/ as a .desktop file. Of course you can also create a service menu for shrinking the pdf afterwards.

Bruni
  • 10,542