Cannot show PDF when not OCR'ed

Discussions about PDF management.
Post Reply
eagleman
Posts: 27
Joined: Mon Jan 25, 2010 1:48 pm

Cannot show PDF when not OCR'ed

Post by eagleman » Sat Mar 13, 2010 2:40 pm

Loic,

I have the following issue:

Creating a non OCR PDF:

Code: Select all

iPdfId = oImaging.PdfNewPdf(filename);
imageID = oImaging.TwainAcquireToGdPictureImage(.....);
oImaging.PdfAddImageFromGdPictureImage(iPdfId, imageID);
oImaging.PdfEndPdf(iPdfId);
When I try to view the created PDF, an error occurs: "The file is damaged and could not be repaired"

=============================================================
When I create a PDF which IS ocr'ed, the created PDF can be viewed without any problems:

Code: Select all

iPdfId = oImaging.PdfOCRStart(filename, ........);
imageID = oImaging.TwainAcquireToGdPictureImage(.....);
oImaging.PdfAddGdPictureImageToPdfOCR(iPdfId, imageID, ........);
oImaging.PdfOCRStop(iPdfId);
Please advise.

eagleman

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Cannot show PDF when not OCR'ed

Post by Loïc » Tue Mar 16, 2010 11:39 am

Hi,

Your code is not correct. You just add image into PDF as resource. You have to draw they now ! However, there is a faster way to acquire pages to multipage PDF.
See code bellow:

Code: Select all

 PdfID = oGdPictureImaging.TwainPdfStart( "output.pdf", true, "", "", "", "", "" ); 
 do 
                { 
                    ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage( this.Handle ); 
                    if ( ImageID != 0 ) 
                    { 
                        oGdPictureImaging.TwainAddGdPictureImageToPdf( PdfID, ImageID ); 
                        oGdPictureImaging.ReleaseGdPictureImage( ImageID ); 
                    } 
                }
while (System.Convert.ToInt64(oGdPictureImaging.TwainGetState()) > System.Convert.ToInt64(TwainStatus.TWAIN_SOURCE_ENABLED)); 
oGdPictureImaging.TwainPdfStop( PdfID ); 
Hope this helps !

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest