ps2pdf service menu

Dolphin Service Menus

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

0
Score 50.0%
Description:

This is a service menu for converting postscript files to acrobat pdf files. It make use of the program ps2pdf. It has been tested to work on KDE 3.2.3 on Debian Sarge. Also tested on KDE 3.4
in Ubuntu (Kubuntu) Hoary 5.04
Dependency: ps2pdf , available in most ghostscript packages (gs-common in debian).

To use this file, simply unzip this file and put into the directory /home/username/.kde/share/apps/konqueror/servicemenus

(substitute username with your own username)

Inspired by Aaron J. Seigo,'s article on howto create a service menu,
http://developer.kde.org/documentation/tutorials/dot/servicemenus.html
and the service menu of pdftk (a tool for combining multiple pdf files) http://www.accesspdf.com/pdftk/

Limitation: Only converts 1 file at a time, Cancel does not work with kdialog, pdf file still saved in home folder
Last changelog:

14 years ago

version 0.1: initial public release
version 0.2: file dialog save to extension *.pdf
version 0.3: support for long filename with spaces

assfaceJackson2

14 years ago

If you have genital warts like me and you don't want to have to select a filename to convert the file to pdf, can you replace the Exec action to the following:

Exec=ps2pdf %U `echo "%u" | sed -e 's/.ps/.pdf/g'`

Report

C

clhong

14 years ago

This doesn't work in KDE 3.4 in Ubuntu 5.04 , so I changed version 0.3 without file dialog box back to version 0.2 with file dialog box. I know it is a bit of hassle but hey you just need to click SAVE, or press ENTER in the keyboard a number of times if you select to convert a few files at the same time. Plus you get to choose where to save the pdf file and the filename as well.

Report

Yama

14 years ago

Here's a better version:

ps2pdf "%u" "`echo "%u" | sed -e 's/.ps/.pdf/g'`"

This version has some benefits over the one in the parent post and the original version. Firstly, it works with long filenames (the parent post doesn't).

Secondly, like the parent version it is totally automatic. There is no prompting for a filename; the original name is kept but the extension changes to pdf. Since we're in KDE, renaming the new file is easy (there's no need to prompt). This feature also allows many PDF files to be created at once. Just select as many .ps files as you want and run this service on them. Easy.

Report

tyrerj

14 years ago

IIUC the output file name is optional.

So, all you need is:

ps2pdf %F

Report

ncarver

13 years ago

While ps2pdf with one argument works as desired on the command line, it fails for me in a service menu (KDE 3.4.2).
The sed-based versions work fine, but neither one appears to be quite correct. The first problem is that the substitute command takes a regexp as its first argument. This means that the "." in the pattern means to match any single char--not to literally match a dot. Try running this on a file with a name like testps.ps and see what happens! To fix this, you need to escape the dot like this:
sed -e 's/\.ps/.pdf/'
The second problem is that the "g" option means to apply the substituation globally, so multiple substitutions may take place--probably not what you want.The final possible problem is that correcting the "." will still not necessarily limit this to being applied to an extension which is what you might want. This can be accomplished by using a "$" in the regexp to denote that the .ps must be at the end of the filename:
's/\.ps$$/.pdf/'
(need to protect the $ inside of double quotes, but \ didn't work for some reason, though doubling the $'s did--not sure why).
Now I wanted something more complex to happen with filenames, so that a final .ps would get changed to .pdf, but also: (1) if there were no extension a .pdf would be added and (2) if the .ps "extension" was not final it would get changed to .pdf (e.g., test.ps.save would become test.pdf.save). To accomplish this I ended up with:
Exec=ps2pdf %f "`echo %f | sed -e 's/\.ps$$/.pdf/p' -e '/\.pdf$$/ d' -e 's/\.ps\./.pdf./p' -e '/\.pdf\./d' -e 's/$$/.pdf/'`"
(Translation: if .ps is at the end of the filename, replace it with .pdf, if .pdf was put at end then done, else look for first .ps. in filename and replace with .pdf., if .pdf. inserted then done, else add .pdf to end of filename. If there is a simpler way to do this with sed I didn't see it!)

Report

14 years ago

version 0.1: initial public release
version 0.2: file dialog save to extension *.pdf
version 0.3: support for long filename with spaces

12345678910
product-maker Base: 4 x 5.0 Ratings
Be the first to comment
File (click to download) Version Description Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
updated May 06 2005
added Nov 09 2004
downloads 24h
1
mediaviews 24h 0
pageviews 24h 3
System Tags addon