Save pixmap as an OCR-ed PDF page. Args: compress: (bool) compress, default 1 (True). language: (str) language(s) occurring on page, default "eng" (English), multiples like "eng+ger" for English and German. tessdata: (str) folder name
(self, compress=True, language="eng", tessdata=None)
| 13715 | out.fz_close_output() # Avoid MuPDF warning. |
| 13716 | |
| 13717 | def pdfocr_tobytes(self, compress=True, language="eng", tessdata=None): |
| 13718 | """Save pixmap as an OCR-ed PDF page. |
| 13719 | |
| 13720 | Args: |
| 13721 | compress: (bool) compress, default 1 (True). |
| 13722 | language: (str) language(s) occurring on page, default "eng" (English), |
| 13723 | multiples like "eng+ger" for English and German. |
| 13724 | tessdata: (str) folder name of Tesseract's language support. If None |
| 13725 | we use environment variable TESSDATA_PREFIX or search for |
| 13726 | Tesseract installation. |
| 13727 | Notes: |
| 13728 | On failure, make sure Tesseract is installed and you have set |
| 13729 | <tessdata> or environment variable "TESSDATA_PREFIX" to the folder |
| 13730 | containing your Tesseract's language support data. |
| 13731 | """ |
| 13732 | tessdata = get_tessdata(tessdata) |
| 13733 | from io import BytesIO |
| 13734 | bio = BytesIO() |
| 13735 | self.pdfocr_save(bio, compress=compress, language=language, tessdata=tessdata) |
| 13736 | return bio.getvalue() |
| 13737 | |
| 13738 | def pil_image(self): |
| 13739 | """Create a Pillow Image from the Pixmap.""" |
no test coverage detected