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需要满足的条件三.校对工具的选择四.校对过程五.延伸讨论 事先声明:本文 ...
随机推荐
- [NACOS HTTP-GET] The maximum number of tolerable server reconnection errors has been reached
错误的意思是:已达到可容忍的服务器重连接错误的最大数目.有两个解决思路:一个将这个值设置的更大:然后是排查自己连接服务哪儿出了问题.先说在哪儿设置这个值:在拉取nacos服务的注解配置中,添加一个属性 ...
- Swoole高效跟传统的web开发有什么区别?
一.swoole的运行模式 Swoole高效跟传统的web开发有什么区别,除了传统的LAMP/LNMP同步开发模式,swoole的异步开发模式是怎么样的. 1.1.传统web开发模式 PHP web开 ...
- luogu P1356 数列的整数性 |动态规划
题目描述 对于任意一个整数数列,我们可以在每两个整数中间任意放一个符号'+'或'-',这样就可以构成一个表达式,也就可以计算出表达式的值.比如,现在有一个整数数列:17,5,-2,-15,那么就可以构 ...
- es6 babel 安装以及使用
1,安装好node(需要使用npm包管理工具) 2,在本地项目路径下npm init,格式化成功后会在项目下生成一个配置文件package.json 3,本地安装bable npm install - ...
- tableview封装使用
下载地址 使用方法 1. #import "ZFTableView.h" 2.在需要使用的地方添加ZFTableView 如下 ZFTableView *ta ...
- hdu3791二叉搜索树
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3791 题意:给定一个n(多组,n为0时结束),给一个串和n个串,分别判断n个串按序列构建的二叉搜索树和 ...
- CodeForces-508A~D篇 div.2
链接:https://codeforc.es/contest/1038 A题: #include<bits/stdc++.h> using namespace std; typedef l ...
- Oracle - 通过dg,完成单实例到rac的迁移
一.概述 本文将介绍如何给单实例搭建一个rac dg,以及如何对其进行角色转换,完成从单实例到rac的迁移.预先具备的知识(rac搭建,单实例-单实例dg搭建) 二.实验环境介绍 主库(已有数据库实例 ...
- nginx之 nginx限流配置
limit_req zone=req_zone;严格依照在limti_req_zone中配置的rate来处理请求超过rate处理能力范围的,直接drop表现为对收到的请求无延时limit_req zo ...
- 【Maven】plugin使用学习
Maven plugin使用学习 官网可用的插件:http://maven.apache.org/plugins/index.html 目录 ============================= ...