PDF thumbnails in Delphi

后端 未结 3 604
温柔的废话
温柔的废话 2020-12-16 00:23

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 s

相关标签:
3条回答
  • 2020-12-16 00:39

    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.
    
    0 讨论(0)
  • 2020-12-16 00:39

    Or if you have "time" you could try using GhostScript either by command line or embedding it. Mike W. gave you a good and easy solution. I use Gnostice but there are many other PDF VCLs solutions.

    0 讨论(0)
  • 2020-12-16 00:55

    You can find a list of installed preview handlers (in Vista and Windows 7) under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers.

    If any PDF handler is installed (e.g. when Acrobat Reader is installed), you can look for the COM server by searching for the GUID found before. This in combination with the IPreviewHandler interface may guide you to a solution.

    0 讨论(0)
提交回复
热议问题