简体   繁体   中英

How to convert scanned PDF to searchable PDF in Python? [Environment:Windows]

I have scanned pdf, I just want to convert searchable PDF by using python. I can convert on Abode but I want to do programmatically and it should be open-source. Can anyone please help to convert the PDF?

Note: It should not remove any image on PDF.

I have solved the problem by using wand package. Example code:

from pdf2image import convert_from_path

from wand.image import Image as WandImage

TIFFPdf = convert_from_path(pdfFileName)
pageNumber = 0
for img in TIFFPdf:
        pageNumber = pageNumber + 1
   
        img1 = WandImage()
        img1.read(filename='suresh.pdf' + '[' + str(pageNumber) + ']', resolution=300)
        img1.compression = 'group4'
        img1.save(filename=str(pageNumber) + '.tif')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM