22 August 2013

Custom action on right click: Convert pdf to png


This is for Linux / KDE

Sometimes I need to convert a pdf to png (1 or more pages). There is a simple command that does that, but I'd like it to be simpler.


Well, the trick is:

1. Copy the text below in a text file


[Desktop Entry]
Type=Service
ServiceTypes=application/pdf
Actions=Convert_PDF_to_PNG

[Desktop Action Convert_PDF_to_PNG]
Name=Convert_PDF_to_PNG
Exec=convert -density 300 %u %d/`basename %u .pdf`.png
Icon=kfm



2. Save it as  ~/.kde/share/apps/konqueror/servicemenus/pdf_to_png.desktop


Now, if you right click over a pdf, in Actions you should see your script.

If the pdf has multiple pages, you will have multiple png files.

-----------

Let me explain this just in case you want to modify it

Exec=convert -density 300 %u %d/`basename %u .pdf`.png

The command is  "convert -density 300  in.pdf  out.png"
%u is the URL  to the selected file
%d is the location of the file
with `basename %u .pdf`.png     I get the /path/to/in.pdf to  just   "in"  and then add ".png", otherwise the png files would be named   "in.pdf.png"
  

0 Comments:

Post a Comment

<< Home

Too Cool for Internet Explorer