PDA

View Full Version : Best way to print using a pdf template



sfabel
29th March 2011, 23:38
Hi all,

my application is basically a form to be filled out, including a couple of images. I am using poppler-qt4 to load a pdf template that contains the never changing stuff. However, now I am running into dpi problems, i.e. the graphics and the text are blurry, even with anti aliasing on.

It seems as if the dpi settings between QPrinter and the Poppler::Document are not the same. Before I get into this any more, what's the best way to go about this problem? QTextDocument seems to be pretty cumbersome to implement, isn't there a better way to just load a PDF that contains most of the stuff and just fill it in automatically with values entered?

Thanks,
Stephan

wysota
30th March 2011, 11:42
First of all antialiasing is what makes things blurry, not the dpi. Second of all it's probably the matter of scaling the pdf's image to the size of the paint device you are applying it on. As far as I remember Poppler should allow you to specify the size of the image you want to receive from the pdf page. You have to calculate the size based on the resolution of the printer and request a proper size from Poppler. Then make sure the image is not scaled.

sfabel
30th March 2011, 18:43
What makes it blurry is that the dpi's do not match, and it's trying to use anti-aliasing to compensate for the jaggedness of the bitmapped pdf. Instead of loading a pdf and being able to just add to it, I have to load it as image "background" on my painter associated with my printer.

What I am doing now is a work around: I load the pdf at twice the dpi that I need it to, then rescale when painting in order to keep the filesize (and load) in check - if I just use QPrinter::HighResolution (1200 dpi), the resulting pdf is 3.1 MB large, and my program is greying out (ie. not reacting) for about 25 seconds.

I am asking if there's another way.

Stephan

jpujolf
31st March 2011, 09:15
Have you tried to use an SVG file for the template ? You can design it in any size and scale it without loosing precision.