ImageEn, unit iexUserInteractions

PDFium PlugIn


PDFium is a Google library providing support for Adobe PDF files.

ImageEn uses PDFium to support PDF in two ways:

1. PDF Viewer

By enabling the PdfViewer property, you can view and manipulate files in a TImageEnView. The following features are supported:
- Scaling and auto-fit options
- View all pages at once *
- Page and document rotation
- Editing of form fields
- Importing, Exporting, deleting and moving * of pages
- Saving of changed PDF files
- Selection of text and images * with clipboard support
- Text searching and highlighting
- High quality printing and exporting to bitmap
- GetBookmarks and Page thumbnail viewer with one-click navigation *
- Access to file attachments
- Keyboard shortcuts
- Web Link support
- Display navigation buttons and PDF annotations




2. Rasterized PDF Loading

When the PDFium plug-in is available and registered, ImageEn can load PDF pages in the same way as multi-frame images.
For best quality you should load the page at the intended display size using LoadFromFilePDF or by specifying the auto-scaling properties.


Notes
- Items marked by are ImageEn custom features (not available in standard PDFium)
- PDFium support requires Delphi/BCB 2009 or newer
- Download the PDFium plug-in from: http://www.imageen.com/download/
- It needs to be registered once by your application
- Distributions must include the copyright notices that are included with the ImageEn PDFium installation
- Specify which page to load using ImageIndex (between 0 and ImageCount-1) or use a TImageEnMView to load and display all pages


Demos

Demo  Demos\Other\PdfViewer\PdfViewer.dpr
Demo  Demos\Other\PdfViewerToolbar\PdfViewerToolbar.dpr
Demo  Demos\Actions\Actions_PdfViewer\PdfViewerActions.dpr


Examples

// Register the PDFium Plug-In
IEGlobalSettings().RegisterPlugIns([ iepiPDFium ]);

// Display a PDF document (and allow text and image selection, scaled viewing, etc)
ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.MouseInteractGeneral := [ miPdfSelectText, miPdfSelectRgn ];
ImageEnView1.IO.LoadFromFilePDF( 'C:\document.pdf' );

// Display a PDF document and image selection (no text selection)
ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.MouseInteractGeneral := [ miPdfSelectRgn ];
ImageEnView1.IO.LoadFromFilePDF( 'C:\document.pdf' );




// Display a PDF page (as an image)
ImageEnView1.PdfViewer.Enabled := False; // Default is false anyway
ImageEnView1.IO.LoadFromFilePDF( 'C:\document.pdf' );

// Display third page of a PDF document
ImageEnView1.IO.Params.ImageIndex := 2;
ImageEnView1.IO.LoadFromFilePDF( 'C:\document.pdf' );

// Enable form editing
ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.PdfViewer.AllowFormEditing := True;
ImageEnView1.IO.LoadFromFilePDF( 'C:\document.pdf' );




// Display all pages of a PDF in a TImageEnMView
ImageEnMView1.MIO.LoadFromFilePDF( 'C:\document.pdf' );

// Show thumbnail preview of all pages of a PDF document
ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.AttachedImageEnView := ImageEnView1;
ImageEnView1.IO.LoadFromFilePDF( 'C:\document.pdf' );




// Convert a multi-page PDF file to TIFF
// Ensure iepdf32.dll is in the EXE folder
mbmp := TIEMultiBitmap.Create( 'D:\multi.pdf' );
mbmp.Params[0].TIFF_Compression := ioTIFF_LZW;
mbmp.DuplicateCompressionInfo();
mbmp.Write( 'D:\Converted.TIFF' );
mbmp.Free;

// Save all pages of a PDF file to PNG
filename := 'C:\doc.pdf';
outputFolder := 'D:\';
IEGlobalSettings().PdfViewerDefaults.DPI := 144; // PDF files are 72 DPI, so 144 is 200% size
bmp := TIEBitmap.Create;
bmp.ParamsEnabled := True;
idx := 0;
Repeat
  bmp.Params.ImageIndex := idx;
  bmp.Read( filename );
  bmp.Write( IncludeTrailingBackSlash( outputFolder ) + format( '%s_%d.png', [ ExtractFilename( filename ), idx+1 ] ));
  inc( idx );
Until idx > bmp.Params.ImageCount - 1;
bmp.Free;



See Also

- TIEPdfViewerInteraction
- PdfViewer
- LoadFromFilePDF