Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
371 views
in Technique[技术] by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...