Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF thumbnails in Delphi

I was wondering if there was an easy of generating thumbnails of PDF files in Delphi. Basically I want to render the first page of a PDF to a small bitmap (say 100x100 or similar).
I see two options 1 use a PDF component, 2 somehow tap into how explorer generates previews/thumbnails.

like image 591
Alister Avatar asked Jan 25 '12 21:01

Alister


People also ask

How do I display a PDF file in Delphi?

Delphi supports the display of Adobe PDF files from within an application. As long as you've got Adobe Reader installed, your PC will automatically have the relevant ActiveX control you'll need to create a component you can drop into a Delphi form. Start Delphi and select Component | Import ActiveX Control...

Does Delphi support Adobe PDF?

He is also proficient in XML, DHTML, and JavaScript. Delphi supports the display of Adobe PDF files from within an application. As long as you've got Adobe Reader installed, your PC will automatically have the relevant ActiveX control you'll need to create a component you can drop into a Delphi form.

How do I install Adobe Acrobat on Delphi?

Start Delphi and select Component | Import ActiveX Control... Look for the "Acrobat Control for ActiveX (Version x.x)" control and click Install. Select the Component palette location into which the selected library will appear. Click Install.

How can I display thumb files in timage?

.thumb files are ordinary png files, just with a different file suffix. Knowing this one can display them in a TImage. First the .thumb extension needs to be registered as new file format. For this include PngImage in your uses and call this: Thanks for contributing an answer to Stack Overflow!


1 Answers

Using a library like QuickPDF or Gnostice is really the easiest option. I'm fairly sure that the PDF thumbnails in explorer are actually generated by whatever PDF software is installed such as Adobe. Unless you can guarantee that a proper PDF reader is installed on every workstation the idea of using thumbnails might not be valid.

Edit: Here's a complete application using QuickPDF to render the first page of a given PDF file into a BMP file. At 10 DPI my output BMP file is 85 pixels wide by 110 pixels high.

program PDFToBMP;
{$APPTYPE CONSOLE}
uses
  SysUtils, QuickPDF;
var
  Q : TQuickPDF;
begin
  Q := TQuickPDF.Create;
  try
    Q.LoadFromFile(ParamStr(1), '');
    Q.RenderPageToFile(10 {DPI}, 1 {PageNumber}, 0 {0=BMP}, ChangeFileExt(ParamStr(1),'.bmp'));
  finally
    Q.Free;
  end;
end.
like image 96
Mike W Avatar answered Sep 20 '22 09:09

Mike W