delphi使用Foxit Quick PDF Library读写pdf文本和图片
简介:
Debenu Quick PDF Library(PDF编程开发工具)提供一套全方位的 PDF API 函数,帮助您快速简便地处理 PDF 文件。从文档属性的基本操作到创建您自己的 PDF 查看器和 PDF 编辑器,这款软件满足您的所有需求。Quick PDF Library是一款供 PDF 开发人员使用的 SDK,功能强大、无需版税,其中包括超过500个函数,可用于 Delphi、C、C#、C++、ASP、VB6、VB.NET、VBScript、PHP、PowerBASIC 等,使用 ActiveX、DLL、LIB 或 Delphi 版本的库
官方帮助文档:https://www.debenu.com/docs/pdf_library_reference/FunctionGroups.php
可以参考(提取文本和图像并插入新PDF):http://quickpdf.org/forum/extract-text-and-images-and-insert-into-new-pdf_topic1308.html
安装:
首先到官网下载该库,官网地址为:http://www.debenu.com/。本文所使用的版本为11.11,下载后得到一个exe文件:foxit_quick_pdf_library_en.exe。双击exe文件即可安装控件库,安装过程中会要求输入安装目录,选择合适的目录完成安装。

文件GettingStarted.pdf介绍了在使用该控件库之前需要做的一些准备工作。首先以管理员身份运行命令提示符并切换到安装目录下,然后输入以下命令完成控件的注册。(我这里安装了两个版本所以有1131的版本)

接着把DebenuPDFLibraryDLL1111.dll、DebenuPDFLibraryDLL1111.pas 添加到Delphi项目中

实例程序
程序记得uses DebenuPDFLibraryDLL1111
unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SynPdf, StdCtrls, DebenuPDFLibraryDLL1111; type
TForm1 = class(TForm)
btn1: TButton;
edt1: TEdit;
edt2: TEdit;
lbl1: TLabel;
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} // 读取pdf文本内容以及图片
function ReadPdf(const fileName, saveImagePath: string; var text: string;
var imageFiles: string): string;
var
rPdf: TDebenuPDFLibraryDLL1111;
imageCount, i, j, num, keyStatus, FH, PR: Integer;
begin
Result := '';
num := ;
if Trim(fileName) = '' then
begin
Result := 'Path cannot be empty';
Exit;
end;
if (Trim(saveImagePath) <> '') and (not DirectoryExists(saveImagePath)) then
begin
ForceDirectories(saveImagePath); // 创建目录
end; rPdf := TDebenuPDFLibraryDLL1111.Create('DebenuPDFLibraryDLL1111.dll'); // 库
keyStatus := rPdf.UnlockKey('**********'); // 密钥 秘钥可以购买或者找我要
if keyStatus <> then
begin
Result := 'The library cannot be loaded or unlocked fails';
Exit;
end;
try
rPdf.LoadFromFile(Trim(fileName), '');
// 以直接访问模式打开文件并存储文件句柄
FH := rPdf.DAOpenFile(fileName, '');
for i := to rPdf.DAGetPageCount(FH) do
begin
rPdf.SelectPage(i); // 选区页
text := text + rPdf.GetPageText(); // 获取文本 8:更准确的文本提取算法
if Trim(saveImagePath) <> '' then
begin
imageCount := rPdf.GetPageImageList(); // 获取图片
for j := to rPdf.GetImageListCount(imageCount) do // 遍历当前页中的所有图片
begin
rPdf.SaveImageListItemDataToFile(imageCount, j, ,
saveImagePath + '\' + IntToStr(num) + '.png');
imageFiles := imageFiles + saveImagePath + '\' + IntToStr(num)
+ '.png ; ';
inc(num);
end;
end;
end;
finally
rPdf.Free;
end;
end; // 写pdf
function WritePdf(const fileName, text: string): string;
var
wPdf: TDebenuPDFLibraryDLL1111;
num, wStatus: Integer;
begin
Result := '';
if Trim(fileName) = '' then
begin
Result := 'Path cannot be empty';
Exit;
end;
try
wPdf := TDebenuPDFLibraryDLL1111.Create('DebenuPDFLibraryDLL1111.dll'); // 库
try
wStatus := wPdf.UnlockKey('*************'); // 密钥
if wStatus = then
begin
num := wPdf.AddTrueTypeSubsettedFont('FangSong', text, );
wPdf.SelectFont(num);
wPdf.DrawWrappedText(, , , text);
wPdf.SaveToFile(fileName);
end
else
begin
Result := 'The library cannot be loaded or unlocked fails';
end;
finally
wPdf.Free;
end;
except
on e: Exception do
Result := e.Message;
end;
end; procedure TForm1.btn1Click(Sender: TObject);
var
text, imageFiles: string;
begin
text := '';
imageFiles := '';
// showmessage(WritePdf(edt1.Text,edt2.Text));
ShowMessage(ReadPdf(edt1.text, edt2.text, text, imageFiles));
lbl1.Caption := text;
ShowMessage(text);
ShowMessage(imageFiles);
end; procedure TForm1.FormCreate(Sender: TObject);
begin
//readAndWritePDf();
end; end.
运行:
提取的:

原本pdf:

delphi使用Foxit Quick PDF Library读写pdf文本和图片的更多相关文章
- C#给PDF文档添加文本和图片页眉
页眉常用于显示文档的附加信息,我们可以在页眉中插入文本或者图形,例如,页码.日期.公司徽标.文档标题.文件名或作者名等等.那么我们如何以编程的方式添加页眉呢?今天,这篇文章向大家分享如何使用了免费组件 ...
- C#添加PDF页眉——添加文本、图片到页眉
页眉常用于显示文档的附加信息,我们可以在页眉中插入文本或者图形,例如,页码.日期.公司徽标.文档标题.文件名或作者名等等.那么我们如何以编程的方式添加页眉呢?今天,这篇文章向大家分享如何使用了免费组件 ...
- quick pdf library控件
quick pdf library库只能在windows环境下运行 1.下载quick pdf library 2.注册控件 进入cmd regsvr32 "C:\Program File ...
- Swift Standard Library Reference.pdf
Swift Standard Library Reference.pdf 下载地址 http://download.csdn.net/detail/swifttrain/7446331 自己的Mark ...
- pure-Python PDF library
# -*- coding: utf-8 -*- # # vim: sw=4:expandtab:foldmethod=marker # # Copyright (c) 2006, Mathieu Fe ...
- 阅读-Calibre Library转PDF、EPUB配置
提示:如果想恢复默认设置,点击"恢复默认值"即可 -----EPUB (MOBI同理)----- 目标:解决转换过程中图片清晰度丢失问题(分辨率太低) 右击-转换书籍-逐个转换 输 ...
- C#写PDF文件类库PDF File Writer介绍
.NET平台开源项目速览(16)C#写PDF文件类库PDF File Writer介绍 阅读目录 1.PDF File Writer基本介绍 2.一个简单的使用案例 3.资源 1年前,我在文章:这 ...
- DjVu、PDF中的隐藏文本
作者:马健邮箱:stronghorse_mj@hotmail.com发布:2012.06.11 目录一.背景二.DjVu中的隐藏文本三.PDF中的隐藏文本 一.背景 目前对于扫描电子文档,网上比较流行 ...
- 校对双层PDF中的隐藏文本
作者:马健邮箱:stronghorse_mj@hotmail.com发布:2012.06.11 目录一.背景二.能够校对的PDF需要满足的条件三.校对工具的选择四.校对过程五.延伸讨论 事先声明:本文 ...
随机推荐
- shell 循环读取文件及字符串转为数组
文件/etc/hdocker_config内容如下: 30.72.63.94 30.72.63.95 30.72.63.96 30.72.63.97 /tmp/lasclocker.tar maste ...
- 2017 CCPC杭州 题解
2017CCPC杭州题目PDF Problem A. Super-palindrome 题解: 给你一个字符串,每一步可以将一个字符替换为另一个字符,问你最少多少步可以使得,该字符串任意奇数子串为回文 ...
- Spring boot 集成 阿里 Mqtt
因为公司业务需求,需要接入 阿里Mqtt,自己基于Spring写了一个小demo,记录下来,已备以后需要. 第一步 创建一个实体bean用来装载 MqttClient private MqttClie ...
- Day 09 作业
简述定义函数的三种方式 有参函数, 无参函数, 空函数 简述函数的返回值 函数内部代码经过一系列的逻辑处理返回的结果 简述函数的参数 函数的参数分形参和实参 形参: 定义函数阶段, 括号内定义的参数, ...
- 【JS】395-重温基础:事件
本文是 重温基础 系列文章的第二十篇. 这是第三个基础系列的第一篇,欢迎持续关注呀!重温基础 系列的[初级]和[中级]的文章,已经统一整理到我的[Cute-JavaScript](http://js. ...
- CSS中的变量使用,var()语法
参考博客:https://blog.csdn.net/qq_34206361/article/details/53690414
- 【Mock MVC】使用学习
[Mock MVC]使用学习 转载:https://www.cnblogs.com/yangchongxing/p/10658311.html
- 2019年Java并发精选面试题,哪些你还不会?(含答案和思维导图)
Java 并发编程 1.并发编程三要素? 2.实现可见性的方法有哪些? 3.多线程的价值? 4.创建线程的有哪些方式? 5.创建线程的三种方式的对比? 6.线程的状态流转图 7.Java 线程具有五中 ...
- 12个超好用的IntelliJ IDEA 插件!你用过几个?
一.前言 IntelliJ IDEA 如果说IntelliJ IDEA是一款现代化智能开发工具的话,Eclipse则称得上是石器时代的东西了. 其实笔者也是一枚从Eclipse转IDEA的探索者,随着 ...
- python爬虫--selenium模块.上来自己动!
selenium 基本操作 from selenium import webdriver from time import sleep #实例化一个浏览器对象 bro = webdriver.Chro ...