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
- User editing of form fields
- Programmatic reading and setting of form field values
- 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 and text
- Bookmark display and Page thumbnail viewer with one-click navigation *
- Access to file attachments
- Keyboard shortcuts
- Web Link and Page Link support
- Display navigation buttons and PDF annotations

* Custom ImageEn features (not available in standard PDFium)

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.

- PDFium support requires Delphi/BCB 2009 or newer
- Download the PDFium plug-in from:
- The plug-in must 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


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


// 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;
ImageEnMView1.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.Write( 'D:\Converted.TIFF' );

// 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;
  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;

See Also

- TIEPdfViewerInteraction
- PdfViewer
- LoadFromFilePDF