ImageEn, unit iexUserInteractions |
|
PDFium PlugIn
PDFium is a Google library providing support for Adobe PDF files. ImageEn offers the most complete implementation of PDFium available for Delphi and C++Builder.
ImageEn uses PDFium to support PDF in three ways:
1. PDF Viewer
By enabling the PdfViewer property, you can view and manipulate files in a TImageEnView. The following features are supported:
* Custom ImageEn features (not available in standard PDFium)
2. PDF Importing
When the PDFium plug-in is available ImageEn can
import objects from PDF pages as
vector objects that can be edited and manipulated to be saved back to PDF, SVG or other image formats.
3. Rasterized PDF Loading
When the PDFium plug-in is available 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
◼PDFium support requires Delphi/BCB 7 or newer
◼Download the PDFium plug-in from:
www.imageen.com/download/
◼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
◼For Windows 7 and earlier, use v5579 of the plug-in
| Demos\PDF\PDFViewer\PdfViewer.dpr |
| Demos\PDF\PDFViewerToolbar\PdfViewerToolbar.dpr |
| Demos\Actions\Actions_PdfViewer\PdfViewerActions.dpr |
| Demos\PDF\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 document and allow editing of the page objects and annotations
ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.PdfViewer.AllowObjectEditing := True;
ImageEnView1.MouseInteractGeneral := [ miPdfSelectObject, miPdfSelectAnnotation ];
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.DuplicateCompressionInfo();
mbmp.SaveToFile( '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.LoadFromFile( filename );
bmp.SaveToFile( IncludeTrailingBackSlash( outputFolder ) + format( '%s_%d.png', [ ExtractFilename( filename ), idx+1 ] ));
inc( idx );
Until idx > bmp.Params.ImageCount - 1;
bmp.Free;
See Also
◼TIEPdfViewer
◼PdfViewer
◼LoadFromFilePDF