ImageEn, unit imageenio




function LoadFromFilePDF(const FileName: string; Width: Integer = -1; Height: Integer = -1; const Password: string = ''): Boolean;


Loads a PDF image PDF into the attached TImageEnView or TIEBitmap using a plug-in.
You can optionally specify a size to load the PDF file to improve quality (the size will be automatically adjusted to maintain the aspect ratio). If the file is encrypted you will need to specify the password.
Result will be false if the file is not PDF format or no PDF plug-ins are available (Aborting will be true). Loading errors due to a file not being available will raise an exception.

PDF loading requires one of the following plug-ins:
- ImageEn PDFium Plug-in
- WPViewPDF commercial plug-in
- ImageMagick + GhostScript

- PDF loading creates a rasterized image of each page (unless PdfViewer = True)
- To manipulate PDF files, enable PdfViewer
- Use ImageIndex to specify which page of the PDF file to load
- Read more about ImageEn PDF Support


// Load the 3rd page of a PDF file with max dimensions of 1000x1000
ImageEnView1.ImageIndex := 2;
ImageEnView1.IO.LoadFromFilePDF( 'C:\Test.pdf', 1000, 1000 );

// Display a PDF document
ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.IO.LoadFromFilePDF( 'C:\document.pdf' );

// Merge two PDF documents
ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.IO.LoadFromFilePDF( 'C:\document.pdf' );
ImageEnView1.PdfViewer.ImportPages( 'C:\morepages.pdf' );
ImageEnView1.IO.SaveToFilePDF( 'C:\merged.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' );

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

See Also

- PdfViewer
- PdfViewerDefaults