PDF文档中的快照图像 [英] snapshot image from PDF document

查看:166
本文介绍了PDF文档中的快照图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从PDF文档中的任意页面(不一定是第一页)中制作快照图像.有免费的工具吗?我正在使用Delphi.
TIA
史蒂文

I want to make a snapshot image from an arbitrary page (i.e. not necessarily the first) in a PDF document. Any free tools for this? I'm using Delphi.
TIA
Steven

推荐答案

史蒂文

几年前,我遇到了同样的问题,唯一可靠的解决方案是购买Acrobat Professional(7)并用它来提取页面,将其复制到剪贴板,然后从中创建缩略图.我很想知道是否有免费的方法可以从pdf文档中提取页面.

I had the same problem a couple years ago and the only reliable solution was to buy Acrobat Professional (7) and use that to extract the page, copy it to the clipboard and then create a thumbnail from that. I'd be very interested to see if there are free methods available to extract pages from a pdf document.

    procedure TFormMain.LoadPDFDoc(Filename: TFilename; var Bitmap: TBitmap);
var
  PDPage : variant;
  PdApp, PdDoc, PdRect: variant;
begin
  try

    PdApp  := CreateOleObject('AcroExch.App');
    PdDoc  := CreateOleObject('AcroExch.PDDoc');
    PdRect := CreateOleObject('AcroExch.Rect');

    //Open the pdf document
    PDDoc.Open(FileName);
    PDPage := PDDoc.AcquirePage(0);

    //Define the rectangle to fit the page
    PDRect.Top    := 0;
    PDRect.Left   := 0;
    PDRect.Right  := PDPage.GetSize.x;
    PDRect.Bottom := PDPage.GetSize.y;

    //Set the bitmap proportions
    with Bitmap do
      begin
        Width  := PDRect.Right;
        Height := PDRect.Bottom;
      end;

    //Copy the rectangle to the ClipBoard
    PDPage.CopyToClipboard(PDRect, 0, 0, 100);
    if not VarIsEmpty(PDPage) then
      PDPage := UnAssigned;

    //Close the pdf document
    PDDoc.Close;

    //Paste the image from the clipboard
    with Bitmap do
      begin
        LoadFromClipboardFormat(CF_BITMAP, ClipBoard.GetAsHandle(CF_BITMAP), 0);
        PixelFormat := pf24Bit;
        HandleType := bmDIB;
      end;

  Except on E: Exception do
    ShowMessage(E.Message);
  end;
end;

问候,彼得

这篇关于PDF文档中的快照图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆