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

Benoît Minisini benoit.minisini at gambas-basic.org
Mon Feb 5 19:24:15 CET 2024


Le 05/02/2024 à 12:57, Claus Dietrich a écrit :
> Am 05.02.24 um 09:09 schrieb Fabien Bodard:
>>
>> Can you make a short project that show us the way you use documents 
>> view and poppler.
>>
>> The image generated by gb.poppler have a static size. So zooming with 
>> documents view lead to a blurry image. I think your problem come from 
>> there...
>> I will try to give you a working example and see I something have to 
>> be done
>>
> Two minimum demo projects (one each for gb.pdf and gb.poppler) have 
> already been provided with this post: 
> https://lists.gambas-basic.org/pipermail/user/2024-February/081388.html
> 
> The projects show a simple loading of a PDF file, rendering and 
> displaying in a DocumentView. The text in the gb.poppler version is 
> already blurred without any zooming(!).
> 
> Hans and I would be grateful for any working example.
> 
> With best regards
> 
> Claus
> 

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.

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...

Regards,

-- 
Benoît Minisini.



More information about the User mailing list