Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting pdf to image but after zooming in

This link shows how pdfs could be converted to images. Is there a way to zoom my pdfs before converting to images? In my project, i am converting pdfs to pngs and then using Python-tesseract library to extract text. I noticed that if I zoom pdfs and then save parts as pngs then OCR provides much better results. So is there a way to zoom pdfs before converting to pngs?

like image 238
user2543622 Avatar asked Mar 22 '19 17:03

user2543622


People also ask

How do I convert a PDF to an image without losing quality?

Select the PDF you want to convert to an image with the help of our PDF to JPG converter. Select the desired image file format. Click Convert to JPG. Download your new image file or sign in to share it.

How do I convert a PDF to a PNG without losing quality?

Open the PDF file with preview in Mac and at the top, click on the File menu and select "Export." Step 2. On the Export window, change the format to "PNG" and adjust quality and resolution accordingly. Now hit "Save," and the PDF file would be converted to PNG.

How do I convert a PDF file to an image?

Use Adobe Acrobat online services to turn your PDF files into JPG images. The Acrobat PDF converter can also create PNG or TIFF file formats. All you need is an internet connection. Fast PDF to image conversion. Drag and drop or upload the PDF document you want to convert to an image file. Then select the PNG, TIFF, or JPG format needed.

How do i Zoom in on a PDF document?

The actual size for a PDF page is typically 100%, but the document may have been set to another magnification level when it was created. Click the Zoom In button or the Zoom Out button in the toolbar.

How to convert PDF to JPG with ease?

Drag and drop your file in the PDF to JPG converter. Select ‘Convert entire pages’ or ‘Extract single images’. Click on ‘Choose option’ and wait for the process to complete.

How do I convert a PDF to a PNG file?

Acrobat online services let you quickly turn PDF files into PNG, TIFF, or JPG images using any web browser, such as Google Chrome. Just choose your preferred file format. The Acrobat conversion process happens in seconds, with image quality you can trust.


1 Answers

I think that raising the quality (resolution) of your image is a better solution than zooming into the pdf.

using pdf2image you can accomplish this quite easily:

install pdf2image: pip install pdf2image

then, in python, convert your pdf into a high quality image:

from pdf2image import convert_from_path

pages = convert_from_path('sample.pdf', 400) #400 is the Image quality in DPI (default 200)

pages[0].save("sample.png")

by playing around with the quality parameter you should get the result you desider

like image 56
Liam Avatar answered Oct 17 '22 22:10

Liam