[英]No output for OCRmyPDF
我正在使用 OCRmyPDF 提取文本形式的掃描 pdf 文件。 為此,我使用了這個 Colab 筆記本中的代碼。 唯一的區別是,我沒有從在線 url 下載 pdf 文件,而是使用存儲在本地計算機上的 pdf 文件而不是 {in_pdf} 文件。 一切看起來都很好,直到我運行:
os.system(f'ocrmypdf {file_name} output.pdf')
當我運行.ocrmypdf Performance Evaluations.pdf output.pdf
時,我得到的不是 0,而是 512,下一行,我收到一條無法識別的錯誤消息,內容如下:
usage: ocrmypdf [-h] [-l LANGUAGE] [--image-dpi DPI]
[--output-type {pdfa,pdf,pdfa-1,pdfa-2}] [--sidecar [FILE]]
[--version] [-j N] [-q] [-v [VERBOSE]] [--title TITLE]
[--author AUTHOR] [--subject SUBJECT] [--keywords KEYWORDS]
[-r] [--remove-background] [-d] [-c] [-i] [--oversample DPI]
[-f] [-s] [--skip-big MPixels] [--max-image-mpixels MPixels]
[--tesseract-config CFG] [--tesseract-pagesegmode PSM]
[--tesseract-oem MODE]
[--pdf-renderer {auto,tesseract,hocr,sandwich}]
[--tesseract-timeout SECONDS]
[--rotate-pages-threshold CONFIDENCE]
[--pdfa-image-compression {auto,jpeg,lossless}]
[--user-words FILE] [--user-patterns FILE] [--skip-repair]
[-k] [-g] [--flowchart FLOWCHART]
input_pdf_or_image output_pdf
ocrmypdf: error: unrecognized arguments: output.pdf
最后,運行以下行:
with pdfplumber.open('output.pdf') as pdf:
page = pdf.pages[0]
text = page.extract_text(x_tolerance=2)
print(text)
返回
FileNotFoundError Traceback (most recent call last)
<ipython-input-19-8274f7005856> in <module>()
----> 1 with pdfplumber.open('output.pdf') as pdf:
2 page = pdf.pages[0]
3 text = page.extract_text(x_tolerance=2)
4 print(text)
/usr/local/lib/python3.6/dist-packages/pdfplumber/pdf.py in open(cls, path_or_fp, **kwargs)
56 def open(cls, path_or_fp, **kwargs):
57 if isinstance(path_or_fp, (str, pathlib.Path)):
---> 58 fp = open(path_or_fp, "rb")
59 inst = cls(fp, **kwargs)
60 inst.close = fp.close
FileNotFoundError: [Errno 2] No such file or directory: 'output.pdf'
任何幫助表示贊賞。 謝謝
如果文件名包含空格,則需要將名稱用引號引起來。
ocrmypdf "Performance Evaluations.pdf" output.pdf
或者
ocrmypdf 'Performance Evaluations.pdf' output.pdf
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.