[poppler] (1) blurred text (2) ownership of TextBoxes

Albert Astals Cid aacid at kde.org
Wed Oct 22 10:35:50 PDT 2008


A Dimecres 22 Octubre 2008, vàreu escriure:
> On 2008-10-21, Albert Astals Cid wrote:
> > A Dimarts 21 Octubre 2008, Mark Summerfield va escriure:
> > > Hi,
> > >
> > > I recently started using the poppler library with the Qt4 headers and
> > > have found it easy to use and generally excellent.
> > > For example, see http://www.qtrac.eu/diffpdf.html
> > >
> > > (1)
> > >
> > > I'm now trying to develop a console app that will do 2-up, 4-up, and so
> > > on printing, optionally ignoring each page's margins to maximize the
> > > use of space.
> > >
> > > But unfortunately, I'm getting blurred pages and don't know why.
> > >
> > > I create a QPrinter in PDF mode and switch render hints _on_ for the
> > > poppler document which I render to a QImage. I then create a QPainter
> > > on the printer and switch its render hints _off_---so that it will just
> > > paint the QImage pixel for pixel.
> > >
> > > I've attached (the very rough first cut) of the source (since it is
> > > only 160 lines), in case anyone has the time/inclination to have a
> > > look, esp. since I'm hoping I just did something silly that you'll spot
> > > in a moment:-)
> > >
> > > [Another problem with the program is that poppler seems to default to
> > > 72 dpi, but QPrinter depends on the actual printer driver, so in my
> > > case is 75 dpi.]
> >
> > The problem with printing images that contain text is usually low
> > resolution of the image, you should be able of fixing this asking for a
> > huge image (setting a high xres and yres on renderToImage) that should
> > give you acceptable printouts at cost of high memory usage. For example,
> > the PS renderer when finds a image with transparency, that is not
> > supported by PS, renders a image and puts it in the PS, the used DPI is
> > 300, and some people still complain is too small.
>
> Albert,
>
> Thanks for this information, it has helped.
>
> Another problem I've had is with resolution---poppler works at 72dpi but
> QCoreApplication gives me 75dpi while QApplication gives me 96dpi on one
> machine and 98dpi on another. What would help is if all the methods that
> are dpi dependent could take dpi arguments. For example, you can pass
> dpis to renderToImage() which is great, but not to
> TextBox::boundingBox() which means you must do the conversion manually.

All methods that are dpi dependent take dpi, that is, only the render method, 
that depending the dpi gives a bigger or smaller image, all the other rects 
give you a 0...1 range because it does not matter (or should not) at which 
dpi you paint them.

At least that was the intented use/reason.

Albert

>
> > > (2)
> > >
> > > In the docs it makes clear that you get ownership of Poppler::Document
> > > and Poppler::Page and so must delete them---that's fine, I use
> > > std::tr1::shared_ptr to handle that. But when you do
> > > Poppler::Page::textList() it isn't clear whether you get ownership of
> > > the Poppler::TextBoxes or not? I've assumed that you don't, but I'd
> > > like to know.
> >
> > You assumed wrong, you need to take care of deleing the textboxes. I'll
> > fix the documentation to clearly state that.
>
> OK, I'll delete them once I've finished with them.
>
> Thanks!




More information about the poppler mailing list