VeryPDF Support Team,
I received this software last Friday and have been unsuccessful in using this function "Attach OCRed text layer to original PDF file",
The command I'm using is:
C:\Temp\Test\ocr2any.exe -ocr -ocrmode 1 a.pdf _test\_a.pdf
This does not work and the resultant PDF does not contain OCR data.
Can you provide the proper command?
Any PDF I use is the same, no OCR after using the command I provided. Can you provide the solution without an example PDF?
Thank you,
Customer
---------------------------------------
Please download the latest version of ocr2any.exe from following URL to try again,
XXXXXXXXXXXXXXXXXX
Can you work fine with this version?
VeryPDF
---------------------------------------
Thank you. This version does work. I can now perform OCR on a scanned pdf, but the application always want to create a new file. How can I perform OCR on an existing scanned PDF and add the invisible text layer to the original document. I want to overwrite the original PDF. I have close to 500,000 scanned pdfs in nested directories.
Maybe something like this:
for /r D:\temp %F in (*.pdf) do ocr2any.exe -ocr -ocrmode 1 "%F" "%~dpnF.pdf"
Thank you,
Customer
---------------------------------------
Thank you for your message. If you'd like to set the output filename the same as the input filename, you can use the following command:
for /r D:\temp %F in (*.pdf) do ocr2any.exe -ocr -ocrmode 1 "%F" "%F"
Please note that this method can be very dangerous, as it may damage your input PDF file if something goes wrong during the OCR process. Therefore, I strongly recommend that you output the converted files to a different folder. Once the conversion is complete, please double-check the PDF files in the output folder to ensure that everything is correct. If everything looks good, you can delete the old folder, rename the new folder to the old folder name, and you should be all set.
VeryPDF
---------------------------------------
Thank you.
I understand the danger of saving over original files. The PDFs I'm working with are not the originals.
In fact, the command line that you provided does not overwrite the original file. Using the provided command below deletes the file.
for /r D:temp %F in (*.pdf) do ocr2any.exe -ocr -ocrmode 1 "%F" "%F"
Here are the results of my test :
After running the command, the file(s) disappear.
Can you please provide a solution that actually overwrites the original with a PDF with OCR text embedded?
Thank you,
Customer
---------------------------------------
Thanks for your message, you can run multiple command lines in batch, for example,
for /r D:\temp %F in (*.pdf) do (
ocr2any.exe -ocr -ocrmode 1 "%F" "%~dpnF-temp.pdf"
del "%F"
copy "%~dpnF-temp.pdf" "%F"
del "%~dpnF-temp.pdf"
)
The first command line will output to a temporary file, the following 3 command lines will delete original PDF file, copy temporary file to original PDF file, and delete temporary file, so you may run this batch command lines to try again.
VeryPDF
---------------------------------------
Thank you, I got this working. There is a slight difference between running the commands in the CLI versus using a batch. In the batch file you have to use %% for variables instead of %.
So this worked for me:
for /r "C:\Temp\Test" %%F in (*.pdf) do (ocr2any.exe -ocr -ocrmode 1 "%%F" "%%~dpnF-temp.pdf"
del "%%F"
copy "%%~dpnF-temp.pdf" "%%F"
del "%%~dpnF-temp.pdf")
I also added " around the original path in case there were spaces in the path.
Thanks again for your help, you can close this ticket.
Regards,
Customer
---------------------------------------
Thanks for your message, yes, when you put this command line into a .bat file, you need to use %% to instead of % symbol.
If we can be of any other assistance, please feel free to let us know.
VeryPDF