在Delphi中使用Quick PDF Library Lite

简介

  • Debenu Quick PDF Library是一个功能强大的PDF操作库,可以中添加处理PDF文件的功能,如创建,渲染,打印,密码安全,合并,分割和操作PDF文件。它包含超过900个函数,支持C,C++,C#,Delphi,Objective-C,Python,PHP,Visual Basic,VB.NET,ASP,PowerBASIC,Pascal和其它语言,包括了ActiveX,DLL,LIB,Delphi和Dylib等版本。
  • Debenu Quick PDF Library Lite是其免费精简版,可在应用程序中免费使用和发布,限制如下。

License definition

The full end user license agreement for Debenu Quick PDF Library Lite can be read [online here]>>(http://www.quickpdflibrary.com/products/quickpdf/license.php), but to give you a rough idea of how you can and can't use Debenu Quick PDF Library Lite, here's a few key points:

  • Free. You can use Debenu Quick PDF Library Lite in your applications without needing to pay a licensing fee or any royalty fees for distribution.
  • No reselling. You are not allowed to resell Debenu Quick PDF Library or your license key, but you can embed the software in your application, or distribute it with your system.
  • Compiled applications only. You are not permitted to create your own PDF software libraries using Debenu Quick PDF Library.
    精简版可使用的函数可以参考安装目录中的Debenu Quick PDF Library 11.14 Reference Guide.pdf中Lite Edition Functions列表

下载和安装

首先到官网下载该库,官网地址为:https://www.debenu.com/blog/category/quick-pdf-library-lite。找不到可以从下面这个地址下http://www.quickpdflibrary.com/free/lite.php
下载所需版本的安装文件http://www.debenu.com/downloads/installers/debenu_quick_pdf_library_lite_en.exe?_ga=2.99056022.909023250.1680680730-1863846514.1680680730
下载后得到一个exe文件:debenu_quick_pdf_library_lite_en.exe。双击exe文件即可安装控件库,安装完成后打开刚才所选择的目录,可以看到以下目录与文件(跟下载的版本有关系)。

[Import]
[Samples]
Debenu Quick PDF Library 11.14 Reference Guide.pdf
DebenuPDFLibrary64Lite1114.dll
DebenuPDFLibrary64Lite1114.tlb
DebenuPDFLibraryLite1114.dll
DebenuPDFLibraryLite1114.tlb
GettingStarted.pdf
license.pdf
readme.txt
reasons_to_upgrade.pdf
uninstall.exe

包含32位和64位两个DLL。
使用前先注册需要使用的DLL:
已以管理员身份运行CMD,输入regsvr32 DebenuPDFLibraryLite1114.dll(使用实际下载和使用的DLL名称)注册。
运行Delphi,Component → Import Componet → Import a Type Library → next → 选择 Debenu Quick PDF Library → next → 填写所需信息(默认值不改也可以) → Create unit即可 ,生成名称形如:ebenuPDFLibraryLite1114_TLB.pas
新建项目,在project点右键 → Add 添加刚生成的单元。

Hello world

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,System.Win.ComObj,
  DebenuPDFLibraryLite1114_TLB;

type
  TForm1 = class(TForm)
    btn1: TButton;
    btn2: TButton;
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
var
  pdf: PDFLibrary;
  pid: Integer;
  mm: Double;
begin
 // 创建mm单位,72dot/inch
  mm:= 72/25.4;
  pdf:= CoPDFLibrary.Create as PDFLibrary;
  pid:= pdf.NewDocument;
  pdf.DrawText(10*mm,10*mm,'test');
  pdf.DrawQRCode(20*mm,50*mm,30*mm,'qrcode sample测试',0,0);
  pdf.SaveToFile('d:\1.pdf');
  pdf:= nil;
end;

procedure TForm1.btn2Click(Sender: TObject);
var
  pdf: PDFLibrary;
  pid: Integer;
  mm: Double;
  path: string;
  picname:string;
begin
  path:= ExtractFilePath(Application.ExeName);
  mm:= 72/25.4;
  pdf:= CoPDFLibrary.Create as PDFLibrary;
  pdf.LoadFromFile('d:\1.pdf','');
  pdf.DrawText(50*mm,100*mm,'read and write pdf');
  picname:= path+'1.bmp';
  ShowMessage(picname);
// 正常模式载入图片
  pid:= pdf.AddImageFromFile(path+'1.bmp',0);
  pdf.DrawImage(20*mm,50*mm,30*mm,10*mm);
// 载入图片包含Alpha通道,可包含透明度,透明背景
  pid:= pdf.AddImageFromFile(path+'2.png',2);
  pdf.DrawImage(40*mm,30*mm,30*mm,10*mm);
  pdf.SaveToFile('d:\1.pdf');
  pdf:=nil;
end;

// 下面这个是在网上找到的方法
// https://www.thoughtco.com/delphi-developers-quick-pdf-library-lite-3972284
// 这个不需要Delphi Import Component,导入tlb库,只需要Regsvr32注册DLL,可以直接用,不过没有动态提示,不如上面方法使用方便
// 需Use ComObj
procedure TForm1.btn3Click(Sender: TObject);
var
  QP: Variant;
begin
  QP:= CreateOleObject('DebenuPDFLibraryLite1114.PDFLibrary');
  QP.DrawText(100,100,'hello world!');
  QP.SaveToFile('d:\2.pdf') ;
  QP:= Unassigned;
end;

end.

在Delphi中使用PDF浏览

参考 https://www.thoughtco.com/adobe-acrobat-pdf-files-delphi-applications-1056893
可以导入Abobe pdf reader 或者 Foxit PDF reader 位为ActiveX控件,在程序中使用。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • C++ 开源库列表https://en.cppreference.com/w/cpp/links/libs[htt...
    老陕西阅读 2,200评论 0 0
  • Foxit Quick PDF Library破解版是一款功能强大的PDF编程控件,软件能够帮助用户快速的处理PD...
    skycht阅读 272评论 0 0
  • Getting Started Use the Current Stable Version (7.1) Buil...
    Leonzai阅读 1,978评论 0 3
  • 注:该篇文章摘自于github.com/vhf/free-programming-books,英文版。访问该项目获...
    stuha阅读 3,989评论 0 13
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,568评论 2 45