compress PDF in context menu of Dolphin  [Solved]

Help with the version of MX KDE officially released by the Development Team.
When asking for help, use Quick System Info from MX Tools. It will be properly formatted using the following steps.
1. Click on Quick System Info in MX Tools
2. Right click in your post and paste.
Message
Author
User avatar
debianix
Posts: 185
Joined: Fri May 31, 2024 4:03 pm

compress PDF in context menu of Dolphin

#1 Post by debianix »

Hello!

I have discovered all kinds of nice things in the context menu of Dolphin and have already installed some of them, some with success, some without success, because many of them seem to be outdated and the developers are also unknown.
However, I am very happy with the "Kim" extension. You can tell that you have thought about what should be preconfigured and what should not.

Unfortunately, there is one thing missing from the context menu:
A PDF Compressor.
Something like this: https://github.com/hkdb/Densify
Does anyone know of a reliable PDF compressor tool for the Dolphin context menu that works reliably under MX Linux?
If so, which one?


I am happy about every tip!

I would like to take this opportunity to thank you for the countless good functions that are already preconfigured in Dolphin when you install it. They are all useful and very good functions that make everyday life much easier!

User avatar
Stevo
Developer
Posts: 14843
Joined: Fri Dec 15, 2006 7:07 pm

Re: compress PDF in context menu of Dolphin  [Solved]

#2 Post by Stevo »

Since Densify uses a Ghostscript command:

Code: Select all

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.6 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=[compressed.pdf] "[input.pdf]"
One should be able to create a service menu with that command, if one doesn't already exist.
MXPI = MX Package Installer
QSI = Quick System Info from menu
The MX Test repository is mostly backports; not the same as Debian testing

User avatar
debianix
Posts: 185
Joined: Fri May 31, 2024 4:03 pm

Re: compress PDF in context menu of Dolphin

#3 Post by debianix »

ah okay, I thought there was a ready one that I have overseen.
So I will save thathttps://develop.kde.org/docs/apps/dolph ... ice-menus/ and will dive into this and try it, as soon as time is left :-)
If it still won't work: I will have to go the "LibreOfficeDraw-way" :alien:

User avatar
debianix
Posts: 185
Joined: Fri May 31, 2024 4:03 pm

Re: compress PDF in context menu of Dolphin

#4 Post by debianix »

okay I was too impatient and tried my best to figure this out, and yeah, it works quite well :-)

I saved the following file under ~/.local/share/kio/servicemenus/pdf-compress.desktop

Code: Select all

[Desktop Entry]
Type=Service
X-KDE-Priority=TopLevel
MimeType=application/pdf
X-KDE-Submenu=PDF Komprimieren
Actions=072dpi;150dpi;300dpi;300dpiHQ


[Desktop Action 072dpi]
Name=072dpi (low /screen)
Icon=application-pdf
Exec=gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dPrinted=false -dQUIET -dBATCH -sOutputFile=compressed.pdf "%u"


[Desktop Action 150dpi]
Name=150dpi (medium /ebook)
Icon=application-pdf
Exec=gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dPrinted=false -dQUIET -dBATCH -sOutputFile=compressed.pdf "%u"


[Desktop Action 300dpi]
Name=300dpi (STANDARD /printer)
Icon=application-pdf
Exec=gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dPrinted=false -dQUIET -dBATCH -sOutputFile=compressed.pdf "%u"


[Desktop Action 300dpiHQ]
Name=300dpi (HQ-downsampling /prepress)
Icon=application-pdf
Exec=gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dPrinted=false -dQUIET -dBATCH -sOutputFile=compressed.pdf "%u"
Maybe one can have a look and let me know if the "Exec"-lines with all the arguments and options are already fine, or is there anything that could be improved, to optimize the output file?

I realize that compression is always associated with a loss of quality, but in my research I found about 100 different variants of this Ghostscript command. I have now tried to filter out the best one for me, and here is the result.
I've also read that the syntax has changed slightly from newer Ghostscript versions onwards, which makes me a little unsure.
Since it works here now, it's not so bad, but maybe someone can suggest an optimization :-)

Post Reply

Return to “MX KDE Official Release”