ImageEn, unit iemview

TImageEnMView.AssignPDFDocument

TImageEnMView.AssignPDFDocument


Declaration

procedure AssignPDFDocument(Source: TIEPdfViewer; HighlightSel: Boolean; DoClear: Boolean = True; TextPos: TIEMTextPos = iemtpBottom; OnDemand: Boolean = False);


Description

Fill content with the pages of a PDF document in a PDF Viewer.
If HighlightSel is true, the current page will be also be shown as selected in this TImageEnMView.
Set DoClear to true if you don't wish to clear the existing content.
The name of the layer will be output in the position of TextPos (or use TIEMTextPos(-1) for no text).
If OnDemand is set to true, you must load each PDF page using the OnImageIDRequest event.



Note: The performance of AssignPDFDocument() can be slow with large PDF files, so you are better to use AttachedImageEnView which will automatically load PDF pages on demand


Demo

Demo  Demos\Other\PdfViewer\PdfViewer.dpr


Example

// Show layer content of a TImageEnView in a TImageEnMView. Allow selection of PDFDocument via the TImageEnMView
// Note: You are better to use: ImageEnMView1.AttachedImageEnView := ImageEnView1;

procedure TfMain.btnLoadClick(Sender: TObject);
begin
  if OpenPDF.Execute() = False then
    exit;

  ImageEnView1.PdfViewer.Enabled := True;
  ImageEnView1.IO.LoadFromFile( OpenPDF.Filename );
  ImageEnMView1.AssignPDFDocument( ImageEnView1.PdfViewer, True );
end;

// OnSelectionChanged event of your TImageEnMView
procedure TfrmMain.ImageEnMView1SelectionChanged(Sender: TObject);
begin
  if ImageEnMView1.LockUpdateCount = 0 then // Avoid programmatic selection changes
    ImageEnView1.PdfViewer.PageIndex := ImageEnMView1.SelectedImage;
end;

// OnImageLoaded event of your TImageEnView
procedure TfMain.ImageEnView1ImageLoaded(Sender: TObject);
begin
  ImageEnMView1.SelectedImage := ImageEnView1.PdfViewer.PageIndex;
end;


See Also

 AttachedImageEnView
 PdfViewer