Skip to content

Commit ceef80b

Browse files
committed
typos
1 parent 189a43e commit ceef80b

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

docs/pymupdf4llm/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ The PyMuPDF4LLM API
119119
* `(top, bottom)` yields `(0, top, 0, bottom)`.
120120
* To always read full pages **(default)**, use `margins=0`.
121121

122-
:arg int ocr_dpi: |PyMuPDFLayoutMode_Valid| specify the desired image resolution in dots per inch for applying OCR to the intermediate image of the page. Default value is 300. Only relevant if the page has been determined to profit from OCR (no or few text, most of the page covered by images or character-like vectors, etc.). Larger values do not usually increase the OCR precision. There also is a risk of over-sharpening the image which may decrease OCR precision. So the default value should probably be sufficiently high - in many cases you should see satisfactory results already with values of 150 or 200. Be aware that this value has a O(n²) impact on processing time and memory requirements.
122+
:arg int ocr_dpi: |PyMuPDFLayoutMode_Valid| specify the desired image resolution in dots per inch for applying OCR to the intermediate image of the page. Default value is 300. Only relevant if the page has been determined to profit from OCR (no or few text, most of the page covered by images or character-like vectors, etc.). Larger values do not usually increase the OCR precision. There also is a risk of over-sharpening the image which may decrease OCR precision. So the default value should probably be sufficiently high - in many cases you should see satisfactory results already with values of 150 or 200. Be aware that this value has a quadratic impact on processing time and memory requirements.
123123

124124
:arg callable ocr_function: |PyMuPDFLayoutMode_Valid| if you want to provide your own :ref:`OCR function <pymupdf_layout_ocr_engines>`, specify it here. If omitted (`None`), one of the available built-in OCR engines will be used.
125125

docs/pymupdf4llm/ocr-plugins.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
.. include:: ../header.rst
2+
3+
14
Default OCR Functions
25
======================
36

4-
PyMuPDF4LLM supports default OCR functions. They come in the form of plugins that are present in its `ocr` subpackage. They are based on currently 3 popular OCR engines, Tesseract OCR, RapidOCR and PaddleOCR. Some engines can be combined to make use of their strengths and mitigate their weaknesses. For example, Tesseract OCR is very good at **recognizing** text, while RapidOCR is better at **detecting** text bounding boxes in images with complex backgrounds. By combining the two engines, we can achieve better overall OCR results while at the samne time also reducing the overall OCR processing time.
7+
PyMuPDF4LLM supports default OCR functions. They come in the form of plugins that are present in its `ocr` subpackage. They are based on currently 3 popular OCR engines, Tesseract OCR, RapidOCR and PaddleOCR. Some engines can be combined to make use of their strengths and mitigate their weaknesses. For example, Tesseract OCR is very good at **recognizing** text, while RapidOCR is better at **detecting** text bounding boxes in images with complex backgrounds. By combining the two engines, we can achieve better overall OCR results while at the same time also reducing the overall OCR processing time.
58

69
Here is an overview of the available default plugins:
710

@@ -15,7 +18,7 @@ rapidtess_api RapidOCR + Tesseract OCR Uses RapidOCR for text **detection** an
1518
paddletess_api PaddleOCR + Tesseract OCR Uses PaddleOCR for text **detection** and Tesseract OCR for text **recognition**
1619
============== ========================= =================================================================================
1720

18-
If not explicitely selected via the `ocr_function` parameter, PyMuPDF4LLM will check the availability of the three OCR engines and pick one of the above plugins in the following order of preference:
21+
If not explicitly selected via the `ocr_function` parameter, PyMuPDF4LLM will check the availability of the three OCR engines and pick one of the above plugins in the following order of preference:
1922

2023
1. `rapidtess_api` (if both RapidOCR and Tesseract OCR are available)
2124
2. `paddletess_api` (if both PaddleOCR and Tesseract OCR are available)
@@ -38,7 +41,7 @@ The provided default plugins use the following **"hybrid"** OCR approach:
3841

3942
In this way, all original content (text and other elements) is preserved and only **augmented** with the newly recognized text. This allows for a more accurate and complete text extraction while also preserving the original document structure and formatting as much as possible. It also allows for a more efficient OCR processing since only the non-extractable text is processed by the OCR engine. This can significantly reduce the overall processing time.
4043

41-
It also increases the chances for a successful layout detection, because other original content like vectors remains intact and is not rendered to pixels.
44+
It also increases the chances for a successful layout detection, because other original content like vectors remain intact and will not be rendered to pixels.
4245

4346
Forcing the Choice of a Default Plugin
4447
---------------------------------------
@@ -69,7 +72,7 @@ If you want to use your own OCR function, you can do so as follows::
6972

7073
Your plugin must accept at least the ``page`` parameter which is a PyMuPDF Page object. The other parameters are optional. The plugin must create (or extend) the text of the passed-in page object by simply inserting text (using any of PyMuPDF's text insertion methods). No return values expected.
7174

72-
Be prepared to accept ``None`` or a PyMuPDF Pixmap object as the `pixmap` parameter, which is the rendered image of the page if provided. Parameters ``dpi`` and ``language`` are passed thru from the respective function parameters.
75+
Be prepared to accept ``None`` or a PyMuPDF Pixmap object as the `pixmap` parameter, which is the rendered image of the page if provided. Parameters ``dpi`` and ``language`` are passed through from the respective function parameters.
7376

7477

7578
Selecting Pages for OCR
@@ -110,7 +113,7 @@ The reason is one of the following values:
110113
* "chars_bad": more than 10% of all characters are illegible (i.e. Replacement Unicode characters)
111114
* "ocr_spans": there exist text spans created from previous OCR executions (render mode 3)
112115
* "vec_text": there exist suspected vector-based glyphs
113-
* "img_text": there exist images which probably contains recognizable text
116+
* "img_text": there exist images which (probably) contain recognizable text
114117

115118
Based on this analysis, PyMuPDF4LLM will decide whether to invoke or skip OCR for a page. This is done to optimize processing time and resource usage by only performing OCR when it is likely to yield additional text content that cannot be extracted by other means.
116119

@@ -129,7 +132,7 @@ You can override this logic in the following ways:
129132
analysis = analyze_page(page)
130133
if not analysis["needs_ocr"]:
131134
return None
132-
135+
133136
# if OCR is recommended, you can decide differently based on your own insights, e.g.
134137
if analysis["reason"] == "ocr_spans":
135138
# we might want to accept previous OCR:
@@ -140,3 +143,4 @@ You can override this logic in the following ways:
140143

141144
md_text = pymupdf4llm.to_markdown("input.pdf", force_ocr=True, ocr_function=my_ocr_function, ...)
142145

146+
.. include:: ../footer.rst

0 commit comments

Comments
 (0)