ImageEn, unit iesettings

TIEPdfViewerDefaults


Declaration

TIEPdfViewerDefaults = class
  SelectionColor   : TColor;
  SelectionMerging : Integer;
  HighlightColor   : TColor;
  FormFieldColor   : TColor;
  FormFieldAlpha   : Integer;
  Options          : TIEPdfOptions;
  DPI              : Integer;
end;


Description

Class of PdfViewerDefaults to specify defaults when initializing the PdfViewer and PDF loading methods when using the PDFium PlugIn.

Property Description Default Value
SelectionColor The color of selected text in the PdfViewer clElectricBlue ($00FE8E32)
SelectionMerging Merges closely aligned selections into single ones. Sometimes the words in PDF documents have widely spaced letters that show as multiple selections. If you specify a value other than zero for SelectionMerging, then selections that are less than that number PDF points apart will be merged into one 3
HighlightColor The color of highlighted text when HighlightText is used clTangerine ($00328EFE)
FormFieldColor The color of all editable form fields when form editing is enabled clElectricBlue ($00FE8E32)
FormFieldAlpha The transparency of the form field color fill when form editing is enabled 25
Options Default value for Options [iepoAutoButtons, iepoAnnotations, iepoOptimizeForLCD]
DPI The scale to display PDF documents with PdfViewer and when loading to render to a bitmap System DPI (e.g. 96)


Examples

// Don't draw annotations when rendering PDF files
IEGlobalSettings().PdfViewerDefaults.Options := IEGlobalSettings().PdfViewerDefaults.Options - [iepoAnnotations];

// Highlight form fields with yellow fill
IEGlobalSettings().PdfViewerDefaults.FormFieldColor := clYellow;
IEGlobalSettings().PdfViewerDefaults.FormFieldAlpha := 50;
ImageEnView1.PDFViewer.Update;

// Do not highlight form fields
IEGlobalSettings().PdfViewerDefaults.FormFieldAlpha := 0;
ImageEnView1.PDFViewer.Update;

// Update selection color
IEGlobalSettings().PdfViewerDefaults.SelectionColor := clRed;
ImageEnView1.Update();

// When rendering PDF files adjust for screen DPI
// This is the default, and the typical display size of PDF documents
IEGlobalSettings().PdfViewerDefaults.DPI := Screen.PixelsPerInch; // or Form.CurrentPPI
ImageEnView1.IO.LoadFromFilePDF( 'C:\Test.pdf' );

// When rendering PDF files show at standard size
IEGlobalSettings().PdfViewerDefaults.DPI := 72;    // PDF files are 72 DPI
ImageEnView1.IO.LoadFromFilePDF( 'C:\Test.pdf' );

// When rendering PDF files scale to double size
IEGlobalSettings().PdfViewerDefaults.DPI := 144;    // PDF files are 72 DPI, so 144 is 200% size
ImageEnView1.IO.LoadFromFilePDF( 'C:\Test.pdf' );

// Do not show very close selections as a single selection
IEGlobalSettings().PdfViewerDefaults.SelectionMerging := 0;
ImageEnView1.Update();

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