ImageEn, unit iexHelperFunctions |
|
TIEMultiBitmapHelper.CreateSearchablePDF
Declaration
function CreateSearchablePDF(const DestFilename: String; const DocTitle: String; Language: TIEOCRLanguages = OCR_English_Language; SegmentationMode: TIEVisionOCRPageSegmentationMode = ievOCRAuto; ImageFormat: TIEVisionPDFImageFormat = ievPDFImgFmt_AUTO; const LanguagePath: string = ''): Boolean; overload;
function CreateSearchablePDF(const DestFilename: String; const DocTitle: String; const LanguageCode: string; SegmentationMode: TIEVisionOCRPageSegmentationMode = ievOCRAuto; ImageFormat: TIEVisionPDFImageFormat = ievPDFImgFmt_AUTO; const LanguagePath: string = ''): Boolean; overload;
Description
A shortcut method that creates a
TIEVisionSearchablePDFGenerator object to create a searchable PDF file.
Parameter | Description |
DestFilename | Full path filename for the PDF document |
DocTitle | Title of the PDF document (which shows in the Document Properties) |
Language | The OCR language specified by type or as a language code string (e.g. 'eng', 'fra'). To use multiple languages, separate them with the plus character, e.g. 'chi_sim+eng' (Simplfied Chinese and English) or 'eng+fra+deu' (English, French and German) |
SegmentationMode | Specify the segmentation mode, which describes how text is laid out on the page (generally ievOCRAuto) |
ImageFormat | Image compression format (default is ievPDFImgFmt_AUTO) |
LanguagePath | Folder containing language data files, e.g. eng.TrainedData (or '' for the EXE folder) |
When the
TIEMultiBitmap is attached to a
TImageEnMView:
◼If
Checkboxes are enabled, only checked images will be included. An exception is raised if there are no checked items
◼If
StoreType is not ietNormal, an attempt is made to load full quality images from file. An exception is raised if the files cannot be accessed
◼OnProgress and
OnFinishWork events will fire
Note:
◼You must add the iexHelperFunctions unit to your uses clause
◼You wil require a TrainedData file for the specified language (e.g. "eng.TrainedData"). An exception is raised if it is not found
◼A temporary file named "pdf.ttf" will be created in the Windows temp folder (it is automatically deleted)
◼OCR requires
IEVision. You will need to
register it before calling the method
Method Behaviour
The following call:
ImageEnMView1.IEMBitmap.CreateSearchablePDF( 'D:\out.pdf', 'My PDF', OCR_English_Language, ievOCRAuto );
Is the same as calling:
// Generate PDF from all images in TImageEnMView
pdfGen := IEVisionLib.createSearchablePDFGenerator( PAnsiChar( AnsiString( '' )), PAnsiChar( AnsiString( IEOCRLanguageList[OCR_English_Language].Code )));
pdfGen.setSegmentationMode( ievOCRAuto );
pdfGen.beginDocument( PAnsiChar( AnsiString( 'D:\out' )), PAnsiChar( AnsiString( 'IEVision PDF Test' )));
for i := 0 to ImageEnMView1.ImageCount - 1 do
begin
bmp := ImageEnMView1.GetTIEBitmap( i, True );
bmp.ParamsEnabled := true;
bmp.Params.Dpi := ImageEnMView1.MIO.Params[i].Dpi;
pdfGen.addPage( bmp.GetIEVisionImage() );
ImageEnMView1.ReleaseBitmap( i, False );
end;
pdfGen.endDocument();
pdfGen := nil;
// Create a PDF document from all images in a TImageEnMView
ShowTempHourglass();
ImageEnMView1.IEMBitmap.CreateSearchablePDF( edtFilename.text, 'My PDF', OCR_English_Language, ievOCRAuto );
// Create a PDF document that contains Chinese and English text
ShowTempHourglass();
ImageEnMView1.IEMBitmap.CreateSearchablePDF( edtFilename.text, 'My PDF', 'chi_sim+eng', ievOCRAuto );
// Convert a TIFF file to a searchable PDF document
mbmp := TIEMultiBitmap.create( 'D:\Test_4pages.tiff' );
mbmp.CreateSearchablePDF( 'D:\doc.pdf', 'My PDF', OCR_English_Language, ievOCRAuto );
mbmp.Free;
// Create a searchable PDF file from 3 images
mbmp := TIEMultiBitmap.Create();
mbmp.FillFromList( ['D:\image1.png', 'D:\image2.png', 'D:\image3.png'] );
mbmp.CreateSearchablePDF( 'D:\Out.PDF', 'My Test PDF' );
mbmp.Free;
See Also
◼TIEOCRLanguages◼LanguageExistsInFolder◼IEVisionLanguageCodeToName◼IEVisionLanguageNameToCode