tvn-cosine / tesseract.net

a .net wrapper for Tesseract
GNU General Public License v3.0
24 stars 13 forks source link

Creating a searchable Pdf #27

Open mletni opened 5 years ago

mletni commented 5 years ago

I would like create serchable PDF by using code from Wiki. But when i try use pdfRenderer.BeginDocument("tesseract.net searchable Pdf generation"); I'm getting an error

BeginDocument failed

i used tesseract.net v4.0.0.14 but after update to v4.0.0.16 the error still repeat.

What could I do wrong?

levpius commented 5 years ago

1) Check string tessDataPath = TessBaseAPI.GetDatapath(); See if u get a valid path for this 2) Make sure u use the above path in PDFRenderer constructor This should be the only reason why u get this error. (I was able to reproduce your error when using a bad value for the Tessdata path.)

1242035 commented 5 years ago

I have same problem. Anyone can resolve this?

if i convert

public void BeginDocument(string title)
{
      if ( Native.DllImports.TessResultRendererBeginDocument((HandleRef)this, title) != 1 )
      {
             throw new Exception("BeginDocument failed.");
      }
}

to

public void BeginDocument(string title)
{
       Native.DllImports.TessResultRendererBeginDocument((HandleRef)this, title);
}

then pdf created perfect.