How to print a pdf file to pdf including annotations and force rasterization from the terminal

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

1 Answer

convert seems to rasterize pdfs on the terminal. Soconvert -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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like