cbrunet / python-poppler

Python binding to Poppler-cpp pdf library
GNU General Public License v2.0
95 stars 15 forks source link

Poor image rendering quality #63

Open pratheesh-prakash opened 2 years ago

pratheesh-prakash commented 2 years ago

Hello @cbrunet . Excellent tool. This is one of the fastest ways to generate PDF images. Thanks for building this.

I have tried python-poppler to render a PDF page, following the documentation available at https://cbrunet.net/python-poppler/usage.html. I have used the following code.

import poppler

doc = poppler.load_from_file(PDF_PATH)
renderer = poppler.PageRenderer()

page = doc.create_page(54)
image = renderer.render_page(page, xres=300, yres=300)
image.save('test.png', 'png', dpi=300)

However, the resultant image has poor rendering, compared to the ones generated using pdftocairo. I am assuming that it is an issue with hinting. I am attaching sample images for your perusal. Zoom in to each of the file to see the difference. The font edges are corrugated in case of python-poppler generated image.

pdftocairo python_poppler

bzamecnik commented 2 years ago

@pratheesh-prakash You'll probably need to enable antialiasing:

renderer = poppler.PageRenderer()
renderer.set_render_hint(poppler.RenderHint.text_antialiasing)
image = renderer.render_page( page, xres=300, yres=300)