python-poppler
python-poppler copied to clipboard
Poor image rendering quality
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.
@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)