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 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]

[Desktop Action rasterizepdf]
Name=rasterize pdf
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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.