Skip to content

Commit 4f3b24c

Browse files
committed
Updated
- Issue fixing - PDF Options support added. (beta)
1 parent 226fece commit 4f3b24c

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"phpoffice/phpspreadsheet": "^1.23",
3939
"phpoffice/phpword": "^0.18",
4040
"laravel/framework": "^12.0",
41-
"thiagoalessio/tesseract_ocr": "^2.12",
41+
"thiagoalessio/tesseract_ocr": "^2.13",
4242
"html2text/html2text": "^4.3",
4343
"phpoffice/phppresentation": "^1.0"
4444
},

config/textract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
| For more details please visit - https://github.com/thiagoalessio/tesseract-ocr-for-php#executable
3535
|
3636
*/
37-
'executable_path' => env('TEXTRACT_OCR_EXEC_PATH', null),
37+
'executable_path' => env('TEXTRACT_OCR_EXEC_PATH', 'tesseract'),
3838

3939
/*
4040
| -------------------------------------------------------------------------------------------------------------

src/ExtractorService/Ocr/TesseractOcrRun.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ protected function getOcr(TesseractOcrOptions $ocrOptions = null): TesseractOCR
3535
$ocrOptions = new TesseractOcrOptions();
3636
}
3737
$ocr = new TesseractOCR($this->utilsService->getFilePath());
38+
$ocr->psm(6);
39+
$ocr->config('preserve_interword_spaces', '1');
3840
$ocr->withoutTempFiles();
3941
if ($ocrOptions) {
4042
foreach ($ocrOptions->toArray() as $option_key => $option_value) {

src/Services/UtilsService.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,11 @@ public function getFileMimeType(): ?string
151151
* @param PdfOptions $options
152152
* @return $this
153153
*/
154-
public function setPdfOptions(PdfOptions $options): self
154+
public function setPdfOptions(?PdfOptions $options): self
155155
{
156-
$this->pdf_options = $options;
156+
if (!is_null($options)) {
157+
$this->pdf_options = $options;
158+
}
157159
return $this;
158160
}
159161

0 commit comments

Comments
 (0)