logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
matthewssl  
#1 Posted : Sunday, December 4, 2016 2:36:35 PM(UTC)
matthewssl

Rank: Newbie

Groups: Registered
Joined: 12/3/2016(UTC)
Posts: 1
United States
Location: Washington

FYI - I am using a trial download, I need to confirm this basic functionality will work in my project environment before I buy.

I get the following enigmatic error when I try to process jpg file and output as PDF.[/b]

An exception of type 'Patagames.Ocr.Exceptions.OcrException' occurred in Patagames.Ocr.dll but was not handled in user code
Additional information: Unexpected error code

ExtractTextFromImage works with the same settings and same source .jpg in the same test project (but it obviously does not use the OcrPDFRenderer.)

Any insight?

Code (vb.net):
Code:

    Public Sub Image2Pdf(filename As String)
        '=======Source is a scanned .jpg file that works in the demo "ExtractTextFromImage()"=========
        Dim sourceImage As String = filename
        '========tessdata is located in the website root dir===========
        Dim TessDataPath As String = Server.MapPath("~/")
        Dim outputFile As String = Server.MapPath("~/tempimages/") & "output"

        Using api = OcrApi.Create()
            api.Init(Languages.English, TessDataPath)
            'Create the renderer to PDF file output. The extension will be added automatically
            Using renderer = OcrPdfRenderer.Create(outputFile, TessDataPath)
                '======="output.pdf is created in output directory, however it remains empty=====
                renderer.BeginDocument("Title")
                '=======Error occurs on next line=======
                api.ProcessPages(sourceImage, Nothing, 0, renderer)
                renderer.EndDocument()
            End Using
        End Using
    End Sub

Misc
Visual Studio 2015, Windows10 Home, Dell PC with 12 gig of memory.

Edited by moderator Sunday, December 4, 2016 3:27:22 PM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Sunday, December 4, 2016 3:39:50 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Please make sure that the TessDataPath points to tessdata folder like following

Code:

OcrPdfRenderer.Create("multipage_pdf_file", @"c:\YourApp\tessdata\"))
Guest  
#3 Posted : Sunday, December 4, 2016 10:09:42 PM(UTC)
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
Thanks for insisting. The confusing thing for me is that the init for languages wants the parent folder above tessdata ("c:\[app]\") e,g, (api.Init(languages.English,"c:\app\") while the init for the Renderer wants the tessdata folder included in the pass spec OcrPdfRenderer.Create(outputfile,"C:\[app]\tessdata").

It took me a while to believe that was the case.

Thanks again. The conversion code works now. It's a sale.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.