poppler_page_render_for_printing vs poppler_page_render

Erik Thiele erik.thiele at thiele-hydraulik.de
Tue Jun 11 16:04:49 UTC 2024


Hi

I read a PDF file via poppler and then create a PDF file from it via
cairo. Nothing is really changed. just poppler_page_get_size() and
cairo_pdf_surface_set_size(). You also supplied a C example doing
exactly that.

If the input is a vector image with many lines, then: if I use
poppler_page_render_for_printing, everything is fine. If i use
poppler_page_render, the drawn lines somehow seem to stick to some kind
of grid and lines seem to be too thick, it's basically unusable. But
from your pdftocairo utlility I find: if (png || jpeg || tiff) {
printing = false; } else { printing = true; }, so it seems like I must
always use poppler_page_render_for_printing when doing PDF output.

OK so I must use poppler_page_render_for_printing for PDF output. period.

But if the input PDF is containing a bitmap, I found that if I have a
large bitmap (larger than poppler/CairoOutputDev.cc MAX_PRINT_IMAGE_SIZE
which is 8192) then poppler will downscale it to 8192 maximum dimension.
I am having 2 meter wide 300 dpi image and thus it is downscaled. The
resulting PDF is having grayscale but the original is black and white.
this results in the printer (which is black and white laser printer) to
dither the graytones and that gives very ugly output since the printer
is only 300 dpi.

I can fix that by using poppler_page_render instead of
poppler_page_render_for_printing. Then the large bitmaps are printed
perfectly. But if the input is a vector image, I have a mess. None of
the two functions fit every case. Especially it is not working if my PDF
contains a large bitmap AND some vector stuff at the same time.


I can't change the MAX_PRINT_IMAGE_SIZE without compiling my own version
of poppler.

Do you have any ideas here?

I read the sourcecode and found many points where you make differences
between poppler_page_render and poppler_page_render_for_printing. Maybe
a better way to implement that would be if there would be options to
explicitly set like an option "downscale_if_larger_than_8192" which I
can activate and deactivate. Then make those options settable and
provide a more generic render function. then implement
poppler_page_render and poppler_page_render_for_printing on top of that
new interface for backward compatibility.

What do you think?


Erik



More information about the poppler mailing list