qvm-convert-pdf

51 views
Skip to first unread message

Sam Hentschel

unread,
May 16, 2017, 1:49:25 PM5/16/17
to qubes...@googlegroups.com
Qubes Devs,

I noticed when using the qvm-convert-pdf tool that my PDFs had a really
low quality. I make a lot of scans of important documents that may need
to be reprinted (in good quality). I talked with tasket and he said
that the script currently uses the default resolution of 150 dpi.

I want to try and implement the ability to set the resolution of the
final PDF being created so as to make it more usable in a professional
environment. I would of course leave the ability to just specify a PDF
for backwards compatability. Question is for that default should I also
increase the resolution?

This will probably be my first patch so, help me out if you can. I
really want to help Qubes grow, and think that it is one of the best
pushes in security in a long time.

--
Respectfully,
Sam Hentschel
FD6A 2998 5301 B440 D26B
7040 69D1 CE58 6FA5 BB5A
signature.asc

Sam Hentschel

unread,
May 16, 2017, 1:51:46 PM5/16/17
to qubes-devel

The issue for this on Github is #2812 (sorry for the double post, tasket just reopened it).

Sam Hentschel

unread,
May 17, 2017, 1:22:41 AM5/17/17
to qubes...@googlegroups.com
I have finished the implementation of resolution in the bash scripts (I
believe). I made the qubes-builder, wrote all my changes in there and
pushed them to my fork. How do I go about testing them, the
documentation on that confused me a bit. If all works on my end I'll be
submitting a pull request tonight or tomorrow.
signature.asc

Chris Laprise

unread,
May 18, 2017, 6:33:51 AM5/18/17
to Sam Hentschel, qubes...@googlegroups.com
On 05/17/2017 01:22 AM, Sam Hentschel wrote:
> On Tue, May 16, 2017 at 01:49:09PM -0400, Sam Hentschel wrote:
>> Qubes Devs,
>>
>> I noticed when using the qvm-convert-pdf tool that my PDFs had a really
>> low quality. I make a lot of scans of important documents that may need
>> to be reprinted (in good quality). I talked with tasket and he said
>> that the script currently uses the default resolution of 150 dpi.
>>
>> I want to try and implement the ability to set the resolution of the
>> final PDF being created so as to make it more usable in a professional
>> environment. I would of course leave the ability to just specify a PDF
>> for backwards compatability. Question is for that default should I also
>> increase the resolution?

Since the converter has its own default, it seems natural to let that be
your default... i.e. there is no ppi specified unless its specified to
the qvm-convert-pdf script. But that could mean that conversions started
from nautilus will be low res; having to use CLI for high res.

>>
>> This will probably be my first patch so, help me out if you can. I
>> really want to help Qubes grow, and think that it is one of the best
>> pushes in security in a long time.
>>
>> --
>> Respectfully,
>> Sam Hentschel
>> FD6A 2998 5301 B440 D26B
>> 7040 69D1 CE58 6FA5 BB5A
>
> I have finished the implementation of resolution in the bash scripts (I
> believe). I made the qubes-builder, wrote all my changes in there and
> pushed them to my fork. How do I go about testing them, the
> documentation on that confused me a bit. If all works on my end I'll be
> submitting a pull request tonight or tomorrow.

Did qubes-builder produce an rpm for a template? You can transfer that
to dom0 to install it (if the name is the same as existing template
you'll have to replace it somehow).

OTOH, you can try the changes temporarily by copying them into a test
template.


--

Chris Laprise, tas...@openmailbox.org
https://twitter.com/ttaskett
PGP: BEE2 20C5 356E 764A 73EB 4AB3 1DC4 D106 F07F 1886

Sam Hentschel

unread,
May 18, 2017, 2:13:28 PM5/18/17
to Chris Laprise, qubes...@googlegroups.com
I tested it by replacing the ones in /usr/lib/qubes in another template
and apparently it doesn't change the resolution despite adding it as an
option.

I talked to a couple people who were more knowledgeable on this than I,
and one of them said:

"so, if it is converting fonts to a png, it's just going to become
blurry, because rendering fonts as an image doesn't scale well, and
fonts are designed to scale"

They then went on to tell me that the only way to preserve the text
perfectly would be to use OCR to turn it into plain text.

After sharing with them the link to the ITL's post on the pdf converter
they basically said the best way to preserve resolution would be to not
convert it and instead just sandbox the application (run in a DispVM).

So, I'm starting to have doubts about whether this little endeavour will
work or not. However, I want to try a couple more things (step by step
conversion, and different image formats) before I call it quits.
signature.asc

Unman

unread,
May 18, 2017, 2:28:40 PM5/18/17
to Sam Hentschel, Chris Laprise, qubes...@googlegroups.com
On Thu, May 18, 2017 at 02:13:06PM -0400, Sam Hentschel wrote:
>
> I tested it by replacing the ones in /usr/lib/qubes in another template
> and apparently it doesn't change the resolution despite adding it as an
> option.
>
> I talked to a couple people who were more knowledgeable on this than I,
> and one of them said:
>
> "so, if it is converting fonts to a png, it's just going to become
> blurry, because rendering fonts as an image doesn't scale well, and
> fonts are designed to scale"
>
> They then went on to tell me that the only way to preserve the text
> perfectly would be to use OCR to turn it into plain text.
>
> After sharing with them the link to the ITL's post on the pdf converter
> they basically said the best way to preserve resolution would be to not
> convert it and instead just sandbox the application (run in a DispVM).
>
> So, I'm starting to have doubts about whether this little endeavour will
> work or not. However, I want to try a couple more things (step by step
> conversion, and different image formats) before I call it quits.


An alternative to OCR would, of course, be to use something like
pdftotext wich has always worked pretty well for me.
I used to religiously convert PDFs but now I store them in a minimal
qube and view them in an offline disposableVM.


Chris Laprise

unread,
May 18, 2017, 6:16:09 PM5/18/17
to Sam Hentschel, qubes...@googlegroups.com
On 05/18/2017 02:13 PM, Sam Hentschel wrote:
> I tested it by replacing the ones in /usr/lib/qubes in another template
> and apparently it doesn't change the resolution despite adding it as an
> option.
>
> I talked to a couple people who were more knowledgeable on this than I,
> and one of them said:
>
> "so, if it is converting fonts to a png, it's just going to become
> blurry, because rendering fonts as an image doesn't scale well, and
> fonts are designed to scale"
>
> They then went on to tell me that the only way to preserve the text
> perfectly would be to use OCR to turn it into plain text.
>
> After sharing with them the link to the ITL's post on the pdf converter
> they basically said the best way to preserve resolution would be to not
> convert it and instead just sandbox the application (run in a DispVM).
>
> So, I'm starting to have doubts about whether this little endeavour will
> work or not. However, I want to try a couple more things (step by step
> conversion, and different image formats) before I call it quits.

I think you'll find that advice was incorrect; most fonts were made to
scale to high resolution.

Experiment directly with pdftocairo and options like -r and -antialias
and -mono. When I test with a command like this:

$ pdftocairo -r 300 file.pdf

...I see a dramatic improvement over default font quality. You can even
use higher res -r 600 with -mono for extra sharpness without any
anti-alias "blur".

Sam Hentschel

unread,
May 19, 2017, 12:44:29 AM5/19/17
to Chris Laprise, qubes...@googlegroups.com
Well, then I guess I'll just have to play around wiht settings a bit
more before I give up on this endeavour. I'll check those out tomorrow
when I'm not in the lab. Thanks for giving me a concrete example
tasket!

I'll let you know how it goes over the next couple days.
signature.asc
Reply all
Reply to author
Forward
0 new messages