我正在尝试使用tesseract
和pdftools
软件包将一系列扫描的PDF转换为可搜索的PDF。我已经完成了两个步骤,现在需要将其写回到可搜索的PDF中。
- 读取扫描的PDF
- 运行OCR
- 将其写回到可搜索的PDF中
eg <- download.file("https://www.fujitsu.com/global/Images/sv600_c_automatic.pdf", "example.pdf", mode = "wb")
results <- tesseract::ocr_data("example.pdf", engine = "eng")
R> results
# A tibble: 406 x 3
word confidence bbox
<chr> <dbl> <chr>
1 PFU 96.9 228,181,404,249
2 Business 96.2 459,180,847,249
3 report 96.2 895,182,1145,259
4 | 52.5 3980,215,3984,222
5 No.068 91.0 4439,163,4754,237
6 New 96.0 493,503,1005,687
7 customer's 94.6 1069,484,2231,683
8 development 96.5 2304,483,3714,732
9 di 90.4 767,763,1009,959
10 ing 96.3 1754,773,1786,807
# ... with 396 more rows
另外,我是否可以在Windows的R中调用其他软件包或命令行工具来替代?
C:\Users\tspeidel\AppData\Local\Programs\Tesseract-OCR\tesseract.exe example_1.png out -l eng PDF
上执行此操作。但我还不确定如何使用它。 - Thomas Speidelsystem
函数调用该代码。 - IRTFMresults <- tesseract::ocr("example.pdf", engine = "eng") ; cat(results, file=temp<-tempfile()) ; rmarkdown::render(temp, "pdf_document", "~/test.pdf")
。 - user20650