[Gambas-user] Blurry text when PDF pages are rendered with gb.poppler and displayed with a DocumentView

Claus Dietrich claus.dietrich at freenet.de
Mon Feb 5 23:02:27 CET 2024


Am 05.02.24 um 19:24 schrieb Benoît Minisini:
> Here is the three problems in your code:
>
> 1) 'Document.Layout.Width' and 'Document.Layout.Height' must receive 
> the size of the paper in millimiters.
>
> But 'PdfDocument[].Width' returns a number of pixels.
>
> So you must convert this number of pixels into millimiters.
>
> There is a bug I just fixed, where the page width and height were 
> always using 72 DPI. Now they use the document resolution.
>
> So you must get the fix to be able to do:
>
> Document.Layout.Width = $PDF_Doc[Page].Width / $PDF_Doc.Resolution * 25.4
>
> Otherwise, you must replace $PDF_Doc.Resolution by 72.
>
> 2) The blur comes from the 72 DPI default document resolution.
>
> You can change the document resolution to something higher. For example:
>
> $PDF_Doc = New PdfDocument(Application.Path &/ "k25.1.12.pdf")
> $PDF_Doc.Resolution = 150
>
> Or you can specify the wanted resolution in the Render() method. But 
> in that case, you must update its width and height arguments 
> accordingly, because $PDF_Doc[Page].Width and Height still use the 72 
> DPI document resolution. The simplest is to not specify the width and 
> height arguments, so that Render() computes them itself.
I am doing this already since some days.
> Note that I don't understand why you don't get the blur with 'gb.pdf', 
> as apparently it uses the same 72 DPI default resolution when 
> rendering the Image property. Strange... 

It is indeed very strange. I will test the impact of your news as soon 
as the ppa is up-to-date. However, it is a matter of fact, that PDF 
pages are displayed sharply at a resolution of just 72 dpi with gb.pdf 
(actually 69.83 dpi for reasons I don't know), which makes the 
application quick and responsive. For that reason I am looking for a 
competitive solution with gb.poppler without having to use higher 
resolutions.

In the attempt to get behind the mystery I also used poppler tools like 
pdftocairo and pdftoppm, but without achieving any improvement. Despite 
my incompetence in the C-language I even tried to compare the codes of 
the PDFDocument classes between gb.pdf and gb.poppler. Without knowing 
its relevance - are you now using a different rendering mode? In 
gb.poppler I found the mode GB_IMAGE_BGRA while in gb.pdf I found 
GB_IMAGE_RGB. Could this make a difference? Is gb.poppler using the same 
toolkit, version and API?

On the other hand we have the DocumentView which has to work with a 
gb.poppler-PDFDocument hand in hand and it is hard to get the whole 
picture with the current state of documentation.

Best regards

Claus






More information about the User mailing list