在这篇文章中,我们将为您详细介绍/Java/Flying-Saucer使用HTML或者FTL(Freemarker模板)生成PDF的内容,并且讨论关于javahtml生成pdf包含图片的相关问题。此外
在这篇文章中,我们将为您详细介绍/Java /Flying-Saucer使用HTML或者FTL(Freemarker模板)生成PDF的内容,并且讨论关于java html生成pdf包含图片的相关问题。此外,我们还会涉及一些关于A Benchmark Comparsion of Monocular Visual-Inertial Odometry Algorithms for Flying Robots论文笔记、android 使用itext5 生成pdf、asp.net – 生成PDF,IE和HTTPS错误、c++ 生成pdf的知识,以帮助您更全面地了解这个主题。
本文目录一览:- /Java /Flying-Saucer使用HTML或者FTL(Freemarker模板)生成PDF(java html生成pdf包含图片)
- A Benchmark Comparsion of Monocular Visual-Inertial Odometry Algorithms for Flying Robots论文笔记
- android 使用itext5 生成pdf
- asp.net – 生成PDF,IE和HTTPS错误
- c++ 生成pdf
/Java /Flying-Saucer使用HTML或者FTL(Freemarker模板)生成PDF(java html生成pdf包含图片)
Flying-Saucer使用HTML或者FTL(Freemarker模板)生成PDF
/Java /Flying-Saucer使用HTML或者FTL(Freemarker模板)生成PDF
- 2015年6月4日
飞翔的拖鞋up
Java
分享到:Google+QQ空间QQ好友新浪微博更多5
下载地址:http://pan.baidu.com/s/1i3pJ2PB
PDF导出工具有itext,但是itext对中文支持不好,还有样式CSS支持也不好,使用IReport比较复杂,上手不太容易,怎么办?
幸好有Flying-Saucer这个项目,帮助我们解决了以上问题!Flying-Saucer最重要的是很方便,不需要使用IReport的复杂操作,只会写html就能够做PDF导出的模板。
使用freemarker的思路
1、编写ftl模板
2、使用freemarker生成html
3、根据生成的html在生成PDF
来一张图片,否则无图无真相
项目依赖
<
properties
>
<
servlet
>3.1.0</
servlet
>
<
freemarker
>2.3.22</
freemarker
>
<
flying-saucer
>9.0.3</
flying-saucer
>
</
properties
>
<
dependencies
>
<
dependency
>
<
groupId
>javax.servlet</
groupId
>
<
artifactId
>javax.servlet-api</
artifactId
>
<
version
>${servlet}</
version
>
<
scope
>provided</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>org.freemarker</
groupId
>
<
artifactId
>freemarker</
artifactId
>
<
version
>${freemarker}</
version
>
</
dependency
>
<
dependency
>
<
groupId
>org.xhtmlrenderer</
groupId
>
<
artifactId
>flying-saucer-pdf</
artifactId
>
<
version
>${flying-saucer}</
version
>
</
dependency
>
</
dependencies
>
|
依赖关系图
项目结构图
主要的操作类
PdfUtils
package
org.xdemo.example.pdf;
import
java.io.FileOutputStream;
import
java.io.IOException;
import
java.io.OutputStream;
import
java.util.HashMap;
import
java.util.Map;
import
javax.servlet.http.HttpServletResponse;
import
org.xhtmlrenderer.pdf.ITextRenderer;
import
com.lowagie.text.DocumentException;
import
freemarker.core.ParseException;
import
freemarker.template.MalformedTemplateNameException;
import
freemarker.template.TemplateException;
import
freemarker.template.TemplateNotFoundException;
/**
* PDF生成工具类
* @author Goofy <a href="http://www.xdemo.org">http://www.xdemo.org</a>
*
*/
public
class
PdfUtils {
public
static
void
main(String[] args) {
try
{
Map<Object, Object> o=
new
HashMap<Object, Object>();
o.put(
"name"
,
"http://www.xdemo.org/"
);
String path=PdfHelper.getPath();
generateToFile(path,
"resources/tpl.ftl"
,path+
"resources/"
, o,
"D:\\xdemo.pdf"
);
}
catch
(Exception e) {
e.printStackTrace();
}
}
/**
* 生成PDF到文件
* @param ftlPath 模板文件路径(不含文件名)
* @param ftlName 模板文件吗(不含路径)
* @param imageDiskPath 图片的磁盘路径
* @param data 数据
* @param outputFile 目标文件(全路径名称)
* @throws Exception
*/
public
static
void
generateToFile(String ftlPath,String ftlName,String imageDiskPath,Object data,String outputFile)
throws
Exception {
String html=PdfHelper.getPdfContent(ftlPath, ftlName, data);
OutputStream out =
null
;
ITextRenderer render =
null
;
out =
new
FileOutputStream(outputFile);
render = PdfHelper.getRender();
render.setDocumentFromString(html);
if
(imageDiskPath!=
null
&&!imageDiskPath.equals(
""
)){
//html中如果有图片,图片的路径则使用这里设置的路径的相对路径,这个是作为根路径
render.getSharedContext().setBaseURL(
"file:/"
+imageDiskPath);
}
render.layout();
render.createPDF(out);
render.finishPDF();
render =
null
;
out.close();
}
/**
* 生成PDF到输出流中(ServletOutputStream用于下载PDF)
* @param ftlPath ftl模板文件的路径(不含文件名)
* @param ftlName ftl模板文件的名称(不含路径)
* @param imageDiskPath 如果PDF中要求图片,那么需要传入图片所在位置的磁盘路径
* @param data 输入到FTL中的数据
* @param response HttpServletResponse
* @return
* @throws TemplateNotFoundException
* @throws MalformedTemplateNameException
* @throws ParseException
* @throws IOException
* @throws TemplateException
* @throws DocumentException
*/
public
static
OutputStream generateToServletOutputStream(String ftlPath,String ftlName,String imageDiskPath,Object data,HttpServletResponse response)
throws
TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException, DocumentException{
String html=PdfHelper.getPdfContent(ftlPath, ftlName, data);
OutputStream out =
null
;
ITextRenderer render =
null
;
out = response.getOutputStream();
render = PdfHelper.getRender();
render.setDocumentFromString(html);
if
(imageDiskPath!=
null
&&!imageDiskPath.equals(
""
)){
//html中如果有图片,图片的路径则使用这里设置的路径的相对路径,这个是作为根路径
render.getSharedContext().setBaseURL(
"file:/"
+imageDiskPath);
}
render.layout();
render.createPDF(out);
render.finishPDF();
render =
null
;
return
out;
}
}
辅助类
package
org.xdemo.example.pdf;
import
java.io.File;
import
java.io.IOException;
import
java.io.StringWriter;
import
java.util.Locale;
import
org.xhtmlrenderer.pdf.ITextRenderer;
import
com.lowagie.text.DocumentException;
import
com.lowagie.text.pdf.BaseFont;
import
freemarker.core.ParseException;
import
freemarker.template.Configuration;
import
freemarker.template.MalformedTemplateNameException;
import
freemarker.template.Template;
import
freemarker.template.TemplateException;
import
freemarker.template.TemplateNotFoundException;
/**
* PDF生成辅助类
* @author Goofy <a href="http://www.xdemo.org">http://www.xdemo.org</a>
*
*/
@SuppressWarnings
(
"deprecation"
)
public
class
PdfHelper {
public
static
ITextRenderer getRender()
throws
DocumentException, IOException {
ITextRenderer render =
new
ITextRenderer();
String path = getPath();
//添加字体,以支持中文
render.getFontResolver().addFont(path +
"resources/ARIALUNI.TTF"
, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
render.getFontResolver().addFont(path +
"resources/SIMSUN.TTC"
, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
return
render;
}
//获取要写入PDF的内容
public
static
String getPdfContent(String ftlPath, String ftlName, Object o)
throws
TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException {
return
useTemplate(ftlPath, ftlName, o);
}
//使用freemarker得到html内容
public
static
String useTemplate(String ftlPath, String ftlName, Object o)
throws
TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException {
String html =
null
;
Template tpl = getFreemarkerConfig(ftlPath).getTemplate(ftlName);
tpl.setEncoding(
"UTF-8"
);
StringWriter writer =
new
StringWriter();
tpl.process(o, writer);
writer.flush();
html = writer.toString();
return
html;
}
/**
* 获取Freemarker配置
* @param templatePath
* @return
* @throws IOException
*/
private
static
Configuration getFreemarkerConfig(String templatePath)
throws
IOException {
Configuration config =
new
Configuration();
config.setDirectoryForTemplateLoading(
new
File(templatePath));
config.setEncoding(Locale.CHINA,
"utf-8"
);
return
config;
}
/**
* 获取类路径
* @return
*/
public
static
String getPath(){
return
PdfHelper.
class
.getResource(
""
).getPath().substring(
1
);
}
}
模板文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
></
title
>
<
style
type
=
"text/css"
>
body {
margin-left: 45px;
margin-right: 45px;
font-family: Arial Unicode MS;
font-size: 10px;
}
table {
margin: auto;
width: 100%;
border-collapse: collapse;
border: 1px solid #444444;
}
th,td {
border: 1px solid #444444;
font-size: 10px;
margin-left: 5px;
}
.mcContent {
line-height: 180%;
padding: 20px;
}
.logo {
text-align: center;
}
.title {
text-align: center;
font-weight: bold;
font-size: 20px;
}
.notes {
font-weight: normal;
margin-left: 5px;
margin-right: 5px;
line-height: 18px;
}
.text_content {
margin-left: 5px;
margin-right: 5px;
line-height: 18px;
}
.sum_insured_first_row {
width: 20%;
}
.sum_insured_span {
font-size: 10px;
}
.special_agreements_div {
page-break-before: always;
font-size: 14px;
margin-top: 20px;
}
.special_agreements_div .special_agreements {
font-size: 18px;
font-weight: bold;
}
.title_right {
width: 100%;
margin: 0 auto;
}
.title_right p {
text-align: left;
margin: 0;
margin-left: 50%;
padding: 0;
}
@page {
size: 8.5in 11in;
@
bottom-center
{
content
:
"page "
counter(
page
)
" of "
counter(
pages
);
}
.signature {
margin: 0 auto;
clear: both;
font-size: 16px;
font-weight: bold;
}
.signature_table {
/* font-size: 16px; */
font-weight: bold;
}
</
style
>
</
head
>
<
body
>
作者:<
a
href
=
"http://www.xdemo.org/"
>http://www.xdemo.org/</
a
>
<
div
>
<
p
>你好:${name}</
p
>
<
div
class
=
"logo"
>
<!--这里的图片使用相对与ITextRenderer.getSharedContext().setBaseURL("file:/"+imageDiskPath);的路径-->
图片支持<
img
src
=
"logo1.png"
/>
</
div
>
<
div
>
<
p
>Hello PDF: 中文支持</
p
>
<
div
style
=
"border:1px solid red;color:red;"
>
样式支持,红边框,红字
</
div
>
<
div
style
=
"border:10px solid blue;color:blue;"
>
样式支持,蓝色10像素的边框,蓝字
</
div
>
<
hr
/>
<
table
>
<
tr
style
=
"background:gray;"
>
<
th
>A</
th
>
<
th
>B</
th
>
<
th
>C</
th
>
<
th
>D</
th
>
</
tr
>
<
tr
>
<
td
>100</
td
>
<
td
>29</
td
>
<
td
>32</
td
>
<
td
>43</
td
>
</
tr
>
<
tr
>
<
td
>100</
td
>
<
td
>29</
td
>
<
td
>32</
td
>
<
td
>43</
td
>
</
tr
>
<
tr
>
<
td
>100</
td
>
<
td
>29</
td
>
<
td
>32</
td
>
<
td
>43</
td
>
</
tr
>
<
tr
>
<
td
>100</
td
>
<
td
>29</
td
>
<
td
>32</
td
>
<
td
>43</
td
>
</
tr
>
<
tr
>
<
td
>100</
td
>
<
td
>29</
td
>
<
td
>32</
td
>
<
td
>43</
td
>
</
tr
>
</
table
>
</
div
>
</
div
>
</
body
>
</
html
>
|
注意
本 工具类提供了两种字体支持中文,所以定义样式的时候字体只能用:simsun或者arial unicode MS,否则中文显示不出来,如需其他字体另行添加),另外请注意图片的路径问题,html中z如果有图片,图片的路径则使用这里设置的路径的相对路径,这 个是作为根路径,如
<
div
class
=
"logo"
>
<!--这里的图片使用相对与ITextRenderer.getSharedContext().setBaseURL("file:/"+imageDiskPath);的路径-->
图片支持<
img
src
=
"logo1.png"
/>
</
div
>
|
如果需要PDF的下载,可以通过generateToServletOutputStream这个方法来获取PDF的输出流,然后通过response写到客户端去
转载请注明来源: http://www.xdemo.org/flying-saucer-html-freemarker-pdf/
A Benchmark Comparsion of Monocular Visual-Inertial Odometry Algorithms for Flying Robots论文笔记
摘要:
本文主要比较单目VIO的算法在飞行机器人上运行的性能,测试使用统一数据集为EuRoC。其中评价指标为:姿态估计精度、每帧处理时间以及CPU和内存负载使用率,同时还有RMSE(运行轨迹与真实轨迹的比较指标)。比较的单目VIO分别为:MSCKF、OKVIS、ROVIO、VINS-Mono、SVO-MSF、SVO-GTSAM。其中运用了四个测试平台Intel NUC(desktop PC)、laptop、UP Board(embedded system for flying robots)、ODROID(an embedded PC containing a hybrid processing unit)
介绍:
选择单目的原因是由于单目是可靠状态估计所需的最小单元,而且相对于其他传感器而言,单目更加适合飞行机器人的负载和功耗需求,所以文章选择比较单目的VIO。因为各个单目VIO算法的性能比较都不全面,而且它们都没考虑计算能力限制的需求,所以本文将它们统一起来一起比较。
贡献:
1、全面比较了公开的单目VIO算法
2、提供比较结果的性能
算法介绍:
1)MSCKF(Multi-state constraint Kalman Filter)主要特点是提出一个测量模型,该模型描述了观察到特定图像特征的所有摄像机帧的姿态之间的几何约束,而不需要维持对该时刻3维特征位置的估计。扩展卡尔曼滤波后端实现了基于事件的相机输入的MSCKF形式,后面改为标准的相机追踪模式。
2)OKVIS(Open Keyframe-based Visual-Inertial SLAM)提出基于关键帧处理的思想,对包括关键帧位姿的一个滑动窗口进行非线性优化。文中提出一个基于视觉路标加权的投影误差和加权的惯性误差项组成的代价函数。前端使用多尺度Harris角点检测和提取BRISK描述子,后端使用ceres进行非线性优化。
3)ROVIO(Robust Visual Inertial Odometry)基于EKF的slam算法。提取Fast角特征,以机器人为中心的方位向量和距离参数化3D位姿,从围绕这些特征的图像流中摄取多层次的patch特征。在状态更新中提出光度误差项。
4)VINS-Mono提出基于滑动窗口的非线性优化估计器,前端追踪鲁棒的角特征。提出一种松耦合的传感器数据融合的初始化过程,可以从任意的状态下引导估计量。IMU测量在优化之前先预积分,提出紧耦合的优化方法。提出4自由度的优化位姿图和回环检测线程。
5)SVO+MSF(Semi-Direct Visual Odometry)MSF是在状态估计中融合不同传感器的通用EKF框架。SVO估计的位姿提供给MSF作为通用的位姿传感器输出,然后使用MSF融合IMU数据。由于松耦合的数据结合,姿态的尺度必须近似正确,需要手动设置初始化的值。
6)SVO+GTSAM后端使用iSAM2中执行在线因子图全平滑优化算法,在位姿图优化中提出使用预积分的IMU因子。
结论:
通过额外计算能力可以提高准确性和健壮性,但是在资源受限系统中,需要在计算能力和性能之间找到合适的平衡。在计算能力受限的系统中,ODROID、SVO+MSF算法性能最好,但是牺牲了精度,得出的鲁棒的轨迹;在计算能力不受限的系统中,VINS-Mono显示高精度和很好的鲁棒性。两者折中方案是ROVIO,比ODROID、SVO+MSF有更好的精度,且比VINS-Mono计算需求低。但是ROVIO对每帧处理时间敏感,无法在一些飞行机器人机载系统上使用。
android 使用itext5 生成pdf
看了这里写例子感觉挺简单的http://developers.itextpdf.com/examples/tables-itext5/adding-images-table
生成e文的按照demo也挺好生成的,但是中文出不来。
参考网上的例子
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
会报如下错误:com.itextpdf.text.DocumentException: Font ''STSong-Light'' with ''UniGB-UCS2-H'' is not recognized.
后来参考itext官方的NotoExample.java在pc上生成出来了。在android上不同的就是load字体文件的问题,参考http://stackoverflow.com/questions/22268438/android-itext-using-assets-fonts-and-utf-8-text
集合官方例子最终处理方式如下
BaseFont bfChinese= BaseFont.createFont("assets/simfang.ttf", BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
asp.net – 生成PDF,IE和HTTPS错误
我收到的错误信息是:
Internet Explorer cannot download OutputReport.aspx from www.sitename.com.
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
用于创建PDF的工具是从DataDynamics开始的ActiveReports.一旦创建了PDF,以下是将其发送的代码:
Response.ClearContent() Response.ClearHeaders() response.addheader("cache-control","max-age=1") Response.ContentType = "application/pdf" response.addheader("content-disposition","attachment; filename=statement.pdf") response.addheader("content-length",mem_stream.Length.ToString) Response.BinaryWrite(mem_stream.ToArray()) Response.Flush() Response.End()
注意:如果我没有明确指定缓存控制,那么.NET会代我发送无缓存,所以我已经尝试将cache-control设置为private或public或maxage =#,但这些都不行.
这是扭曲的:当我运行fiddler检查响应标题时,一切都正常.我收到的标题是:
HTTP/1.1 200 OK
Cache-Control: max-age=1
Date: Wed,29 Jul 2009 17:57:58 GMT
Content-Type: application/pdf
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
content-disposition: attachment; filename=statement.pdf
content-encoding: gzip
vary: Accept-Encoding
transfer-encoding: chunked
一旦我关闭了fiddler,再试一次,它再次失败.我注意到的另一件事是,当fiddler正在运行时,我得到一个本网站的安全证书警告消息有问题,我必须点击继续访问本网站(不推荐)才能通过.当fiddler关闭时,我不会遇到此安全警告,并且立即失败.
我很好奇fiddler和浏览器之间发生了什么,所以当fiddler正在运行时,它可以工作,但是当它没有运行时就会中断,但更重要的是,有没有人有任何想法,我可以如何更改我的代码,因此将PDF转换为IE将无需更改到客户机?
更新:fiddler问题得到解决,非常感谢EricLaw,所以现在它的行为一贯(破碎,有或没有fiddler运行).
基于Google搜索,似乎有很多关于这个同样问题的报告遍布网络,每个都有自己的特定组合的响应标题,似乎可以解决个别情况的问题.我尝试过许多建议,包括添加ETag,LastModified日期,删除vary标题(使用fiddler)和数十种Cache-Control和/或Pragma头文件的组合.我尝试“Content-transfer-encoding:binary”以及ContentType的“application / force-download”.迄今为止没有任何帮助.有一个few Microsoft KB articles,所有这些都表示Cache-Control:无缓存是罪魁祸首.任何其他想法?
更新:顺便说一下,为了完整,Excel和Word输出也会出现同样的问题.
更新:没有进展.我通过电子邮件将.ZZZ文件从fiddler发送到EricLaw,并且在调试IE时能够重现问题,但还没有解决方案.赏金会过期…
解决方法
通常,我会说,最可能的罪魁祸首是你的vary标头,因为这样的标题通常会导致IE:http://blogs.msdn.com/ieinternals/archive/2009/06/17/9769915.aspx中的缓存问题.您可能想尝试向响应头添加一个ETAG.
fiddler应该对可缓存性没有影响(除非你已经写了规则),而且听起来像你说的那样,这表明也许有某种时间问题.
>默认情况下,不要将加密的页面保存到用于禁用的磁盘安全选项
默认情况下,此选项仍然禁用(在IE6,7和8中),尽管IT管理员可以通过组策略来启用该选项,而一些主要公司也是这样做的.
顺便说一下,运行fiddler时看到证书错误的原因是您没有选择信任fiddler根证书;有关此主题的更多信息,请参阅http://www.fiddler2.com/fiddler/help/httpsdecryption.asp.
c++ 生成pdf
PDFLib介绍
PDFLib是用于创建PDF文档的开发库,提供了简单易用的API,隐藏了创建PDF的复杂细节且不需要第3方软件的支持。PDFLib库对于个人是免费的,对于商业产品需要购买许可, 您可以到VC知识库的工具与资源栏目下载:http://www.vckbase.com/tools/。
三、在VC++中使用PDFLib
本文例子中使用的PDFLib是4.0.2版本,与5.0版本差不多。5.0免费版本中有一个WWW.PDFLIB.COM的水印,4.0中没有。
3.1 前期准备
建立工程后,将except.cpp,except.h,pdflib.cpp,pdflib.h,pdflib.dll,pdflib.lib拷贝到工程目录。
3.2 编码
3.2.1 添加对头文件和库的引用#include "PDFLib.hpp"
3.2.2生成PDF文档的过程
#pragma comment(lib, "PDFLib.lib")
生成PDF文档的过程非常简单,请看如下编码:int main(void)
PDFLIB还有许多功能,比如书签、PDF导入等功能,具体可以参考PDFLIB函数手册(可以到VC知识库中下载pdflib5.0,里面包含了该手册)。
{
try
{
PDFlib pdf;
// 设置兼容参数
pdf.set_parameter("compatibility", "1.4"); // 兼容Acrobat 5
// 打开文档
if(pdf.open("vckbase.pdf") == -1)
throw("打开文件出错!");
// 设置文档信息
pdf.set_info("Creator", "PDF Creator");
pdf.set_info("Author", "WangJun");
pdf.set_info("Title", "Convert to PDF");
pdf.set_info("Subject", "PDF Creator");
pdf.set_info("Keywords", "vckbase.com");
// 开始A4页面
pdf.begin_page(a4_width, a4_height);
// 设置字体为12号宋体
int font_song = pdf.findfont("STSong-Light", "GB-EUC-H", 0);
pdf.setfont(font_song, 12);
// 设置起始点
pdf.set_text_pos(50, a4_height - 50);
// 设置颜色为蓝色
pdf.setcolor("fill", "rgb", 0, 0, 1, 0);
// 输出文字
pdf.show("VCKBASE.COM欢迎您!");
pdf.setcolor("fill", "rgb", 0, 0, 0, 0);
pdf.setfont(font_song, 24);
pdf.continue_text("在线杂志");
// 画两根绿线
pdf.setcolor("stroke", "rgb", 0.24f, 0.51f, 0.047f, 0);
pdf.moveto(50, a4_height - 80);
pdf.lineto(a4_width - 50, a4_height - 80);
pdf.moveto(50, a4_height - 78);
pdf.lineto(a4_width - 50, a4_height - 78);
pdf.stroke();
// 填充一个蓝色方框
pdf.setcolor("fill", "rgb", 0.04f, 0.24f, 0.62f, 0);
pdf.rect(50, 50, a4_width - 100, 70);
pdf.fill();
// 在指定位置输出文字
pdf.setcolor("fill", "rgb", 0, 1, 1, 0);
pdf.setfont(font_song, 16);
pdf.show_xy("版权所有 VCKBASE", a4_width - 280, 60);
// 打开并显示一个图像
int img = pdf.open_image_file("jpeg", "vckbase.jpg", "", 0);
pdf.place_image(img, 200, 400, 1);
pdf.close_image(img);
// 添加附件
pdf.attach_file(a4_width - 50, 0, 0, a4_height - 150,
"vckbase.zip", "VCKBASE", "wj", "zip", "paperclip");
// 结束本页
pdf.end_page();
// 关闭PDF文件
pdf.close();
}
catch(PDFlib::Exception &ex)
{
cerr << "错误信息:" << ex.get_message() << endl;
return -1;
}
catch(char *pStrErr)
{
cerr << pStrErr << endl;
return -1;
}
catch(...)
{
cerr << "发生未知异常!" << endl;
return -1;
}
return 0;
}
今天的关于/Java /Flying-Saucer使用HTML或者FTL(Freemarker模板)生成PDF和java html生成pdf包含图片的分享已经结束,谢谢您的关注,如果想了解更多关于A Benchmark Comparsion of Monocular Visual-Inertial Odometry Algorithms for Flying Robots论文笔记、android 使用itext5 生成pdf、asp.net – 生成PDF,IE和HTTPS错误、c++ 生成pdf的相关知识,请在本站进行查询。
本文标签: