How to convert scanned PDF to searchable PDF?

May 7, 2015 at 1:40 PM
I've tried and tried, but I keep getting PDF files with 0 bytes:
PDFDoc doc = PDFDoc.Open(@"c:\users\jan\desktop\source.pdf");
doc.Ocr(Clock.Utils.OcrMode.Tesseract, "eng", WriteTextMode.Word, null);
doc.Save(@"c:\users\jan\desktop\hocr.pdf");
What am I doing wrong?
Coordinator
May 8, 2015 at 12:19 AM
DId you install Ghostscript and Tesseract and it still doesn't work?
May 24, 2015 at 6:52 PM
i am doing the same

PDFDoc doc = PDFDoc.Open(openFileDialog2.FileName);
        doc.Ocr(OcrMode.Tesseract,"eng",WriteTextMode.Word,null);
        doc.Save("pdftest.pdf");
i produce empty pdf file the size of file is zero and yes i have tesseract and ghostscript installed
May 24, 2015 at 7:16 PM
Jun 5, 2015 at 10:37 AM
I fixed it by altering the getFileStream() and Save() methods
>         public void Save(string newFile, string password = null)
        {
            // pdfStamper.Close();
            //  iTextReader.Close();
            var mem = GetFileStream();
            var saveToFS = new FileStream(newFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
           
            if (password != null)
            {
                var r = GetReader();
                PdfEncryptor.Encrypt(
                  r,
                  saveToFS,
                  true,
                  null,
                  password,
                  PdfWriter.ALLOW_PRINTING | PdfWriter.ALLOW_COPY
                );
                r.Close();
            }
            else
            {
                mem.CopyTo(saveToFS);
                saveToFS.Close();
                saveToFS = null;
            }

            mem.Close();
            mem = null;
            //    File.Copy(ReaderPDF, newFile);
            GetReader(ReaderPDF).Close();
            GetReader(SourcePDF).Close();
        }
Here the issue was
var saveToFS = new FileStream(newFile, FileMode.Create);
which always creates an empty pdf (Length=0)