Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Adds more documentation for OCR_PAGES and prevents using 0 for actual OCR (#5275)

Trenton H9043f45350b9
diff --git a/docs/configuration.md b/docs/configuration.md
index 30db90c85..5ca6bf701 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -665,11 +665,13 @@ completely.
Specifying 1 here will only use the first page.
+ The value must be greater than or equal to 1 to be used.
+
When combined with `PAPERLESS_OCR_MODE=redo` or
`PAPERLESS_OCR_MODE=force`, paperless will not modify any text it
finds on excluded pages and copy it verbatim.
- Defaults to 0, which disables this feature and always uses all
+ Defaults to unset, which disables this feature and always uses all
pages.
#### [`PAPERLESS_OCR_IMAGE_DPI=<num>`](#PAPERLESS_OCR_IMAGE_DPI) {#PAPERLESS_OCR_IMAGE_DPI}
@@ -683,7 +685,7 @@ fails, it uses this value as a fallback.
Set this to the DPI your scanner produces images at.
- Default is none, which will automatically calculate image DPI so
+ Defaults to unset, which will automatically calculate image DPI so
that the produced PDF documents are A4 sized.
#### [`PAPERLESS_OCR_MAX_IMAGE_PIXELS=<num>`](#PAPERLESS_OCR_MAX_IMAGE_PIXELS) {#PAPERLESS_OCR_MAX_IMAGE_PIXELS}
diff --git a/src/paperless_tesseract/parsers.py b/src/paperless_tesseract/parsers.py
index c699d8ea5..ccddc987e 100644
--- a/src/paperless_tesseract/parsers.py
+++ b/src/paperless_tesseract/parsers.py
@@ -238,7 +238,7 @@ class RasterisedDocumentParser(DocumentParser):
ocrmypdf_args["rotate_pages"] = True
ocrmypdf_args["rotate_pages_threshold"] = self.settings.rotate_threshold
- if self.settings.pages is not None:
+ if self.settings.pages is not None and self.settings.pages > 0:
ocrmypdf_args["pages"] = f"1-{self.settings.pages}"
else:
# sidecar is incompatible with pages