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

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, March 1, 2012 12:23:16 AM(UTC)
jcbautista

Groups: Registered
Posts: 7


Hi!

I have the following code that simply copies the text from one document and then writes it onto another:

// Create a new instance of the LEADTOOLS Document Writer
DocumentWriter docWriter = new DocumentWriter();

//Set the PDF options
PdfDocumentOptions pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;
pdfOptions.AnnotationsEnabled = true;
docWriter.SetOptions(DocumentFormat.Pdf, pdfOptions);
docWriter.BeginDocument(FILE_NAME_PDF_OUT, DocumentFormat.Pdf);

DocumentReaderLoadOptions readerLoadOptions = new DocumentReaderLoadOptions();
DocumentReader reader = DocumentReader.Create(FILE_NAME_PDF, readerLoadOptions);

using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Professional, false))
{
    ocrEngine.Startup(null, null, null, null);
    reader.ObjectManager.BeginParse(ocrEngine);

    foreach (DocumentReaderPage readerPage in reader.Pages)
    {
        DocumentPageText pageText = reader.ObjectManager.ParsePageText(readerPage);
        DocumentPage page = DocumentPage.Empty;
        page.Image = null;
        AnnContainer container = new AnnContainer();

        foreach (DocumentCharacter character in pageText.Characters)
        {
            AnnTextObject text = new AnnTextObject();

            text.Bounds = new AnnRectangle((float)character.Bounds.X, (float)character.Bounds.Y, (float)character.Bounds.Width, (float)character.Bounds.Height);
            text.Text = character.Code.ToString();
            text.Font = new AnnFont(System.Drawing.FontFamily.GenericSansSerif, new AnnLength((float)character.FontSize), System.Drawing.FontStyle.Regular);

            container.Objects.Add(text);
        }

        page.AnnotationContainer = container;
        docWriter.AddPage(page);
    }

    reader.ObjectManager.EndParse();
}

docWriter.EndDocument();


When I get to the highlighted part, I'm getting a RasterException with the message "File not found".

I'm a little confused. I checked the path of the file and it's a valid one. Why would this error appear?

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, March 1, 2012 12:27:17 AM(UTC)
jcbautista

Groups: Registered
Posts: 7


Hmmm...there must be a problem with the text editor as I changed the font of my post to Courier New and highlighted the following line:
docWriter.AddPage(page)


 
#3 Posted : Thursday, March 1, 2012 9:05:47 AM(UTC)

Walter  
Walter

Groups: Tech Support
Posts: 366

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)

The "File not found" error is likely referring to a missing DLL. It likely has to do with either what DLLs you have referenced, or at least what DLLs you have copied into your application Bin. Without being able to test the solution directly (as a small sample application), it's difficult to say exactly what file may be missing. My first guess would be one of the file filter DLLs.

I would find out if this is a DLL issue by trying to run the project from the LEADTOOLS Bin directory. By outputting the EXE there, you'd have access to all of the DLLs. If this makes the application work, you can use Microsoft's Process Explorer utility to find out what DLL is missing from your local Bin directory by seeing what DLLs were loaded. A process of elimination would tell you what to add. If this doesn't fix the issue, then there could be something in the logic of the code that's missing.

If you have an application that you can't easily output to the LEADTOOLS Bin directory, copying ALL of the DLLs into the local Bin would serve the same purpose.

In looking at your code, I am seeing two things that are of interest to me. First, I see that you're initializing the DocumentPage.Image to null. I wasn't sure if this was acceptible or not, so I checked out the documentation for the Image property. It indicates that this is optional. The remarks also walk through a scenario where it is initialized, and the PdfDocumentOptions.ImageOverText is set to true. I don't see you setting this property either way with the given options, so I'm not sure if this may be causing issues as well.

If you continue to have issues with this, it would be helpful if you could provide a small sample project that isolates this issue so we can test this out here as well.

***********
NOTE: If you are attaching a project or file to the forums...
1.) Zip the file(s) up.
2.) Make sure it is less than 5 MB.  If it is larger, please send an email to support@leadtools.com and we'll send you FTP instructions.
3.) Remove ANY AND ALL unlock codes/license files and LEADTOOLS DLLs.
4.) Do not click the preview button, the attachment will not show up when you post it.

If you do not wish to post your file(s) on the forum since they are publicly viewable, please send an email to support@leadtools.com and make sure that you include a link to this forum post.
***********
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.098 seconds.