Convert to Trusted PDF: How to increase the image quality

A. When you convert a PDF to a trusted PDF the result is very poor for text.
Is there a tweak to increase the image quality / resolution of Convert to Trusted PDF?

B. Any plans to have a minimal wizard in future?
Something like:

  • Image quality
    [ ] High - [X] Medium - [ ] Low

  • Coloring
    [ ] Color [X] Black&White only

  • Original PDF file
    [ ] Keep original PDF and name it:
    <file.name>.pdf_untrusted.tar.xz

1 Like

I think to increase PDF quality, you’ll need to edit this part: https://github.com/QubesOS/qubes-app-linux-pdf-converter/blob/28ab96bd64caebf1e51b0a153133468b583e97d1/qubespdfconverter/server.py#L144-L154 , passing larger -rx and -ry parameters to pdftocairo according to its documentation pdftocairo: Portable Document Format (PDF) to PNG/JPEG/TIFF/PDF/PS/EPS/SVG using cairo | poppler-utils Commands | Man Pages | ManKier

1 Like

Thanks @augsch !
I checked your links and with my low-level coding skills I would like to confirm your suggestion even if I am not able to make the final confirmation since I was not able to compile and test the final code.

Concerning B. Maybe @marmarta wants to follow up on this when she gets the devices widget UX ready :wink:

Inspired by your summit presentation:

2 Likes

I went down the same rabbit hole as @augsch yesterday… all the way to the git source :smiley:

Just passing by to mention that the third feature you requested is easy to achieve even now from the command-line: qvm-convert-pdf accepts the “-i” (or "--in-place") option to omit preserving the original pdf.

Cool, thanks for stepping in @barto !

qvm-convert-pdf --help

Usage: qvm-convert-pdf [OPTIONS] [FILES ...]

Options:
  -b, --batch SIZE    Maximum number of conversion tasks
  -a, --archive PATH  Directory for storing archived files
  -i, --in-place      Replace original files instead of archiving them
  --help              Show this message and exit.

I did some tests. Interestingly, I thought the default is --in-place. :thinking:
My PDF file will be replaced without -i and with -i only -a allows me to keep the original pdf. Or is there a default archive where all untrusted PDF are moved?

Well, apparently there is a default place for untrusted pdfs!! Didn’t know that either… but after some quick testing, seems like the untrusted PDFs are moved to /home/user/QubesUntrustedPDFs/ … if this directory exists. And it doesn’t exist by default in my disposable vm.

1 Like

You dont need to compile any code.
You can make a change in the template, or in any template based qube.
The file is at
/usr/lib/python/dist-packages/qubespdfconverter/server.py in Debian
systems.
You can edit it in place adding `“-r 300” at line 148
The default is 150 PPI , so this will double that.

Once you have a setting you like, you can make the change in the
template.
Alternatively you can use a sed script in /rw/config/rc.local to add
that line in place in an individual qube, as you wish. If you need help
with that just ask.

5 Likes

Thank @unman! I will test it this week