Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...