- 浏览: 524091 次
- 性别:
- 来自: 山东济南
文章分类
最新评论
-
dragon_8844:
非常不错,nice
java.util.concurrent 多线程框架 -
wusendong:
很好的文章!受益匪浅,谢谢!
java.util.concurrent 多线程框架 -
SINCE1978:
你也关注并发啊
java.util.concurrent 多线程框架 -
lku1314:
这个不错 刚刚找到这个组建 以前孤陋寡闻了 像lz学习!标 ...
quartz 在WEB中应用小结 -
lliiqiang:
人们对于目标需要的需求明确的去做,对于目标以外的因素是随机的执 ...
flex和后端的数据交互(一)--XML和HTTPService
现在有很多网页页面转换成PDF文档的支持项目,我使用的是pd4ml;一个支持.net和java语言的项目。
这是主页:http://pd4ml.com/ . 有免费版和收费版,看了看免费版,感觉还不错,文档也比较详细。
web应用中需要添加pd4ml.jar和ss_css2,jar;
贴个例子:
ServletContext app; protected Dimension format = PD4Constants.A4; protected boolean landscapeValue = false; protected int topValue = 10; protected int leftValue = 10; protected int rightValue = 10; protected int bottomValue = 10; protected String unitsValue = "mm"; protected String proxyHost = ""; protected int proxyPort = 0; protected int userSpaceWidth = 780; public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String httpurl = request.getParameter("httpurl"); // String urlstring = "http://localhost:8080/Itinerary/ProcessPOIs.jsp"; ItineraryWebSession iws = (ItineraryWebSession) request.getSession().getAttribute("iws"); if (iws != null && request.getSession().getAttribute("email") != null) { String email = (String) request.getSession().getAttribute("email"); app.setAttribute("iws_" + email, iws); httpurl = httpurl + "?pdf=true&email=" + email; // request.getSession().setAttribute("iws", iws); } try { response.reset(); response.addHeader("Content-Disposition", "attachment;filename=" + new String("result".getBytes(), "8859_1")); // response.addHeader("Content-Length", "" + file.length()); BufferedOutputStream output = null; try { output = new BufferedOutputStream(response.getOutputStream()); this.runConverter(httpurl, output); response.flushBuffer(); } catch (Exception e) { e.printStackTrace(); } finally { if (output != null) output.close(); } } catch (Exception e) { e.printStackTrace(); // TODO: handle exception } } public void runConverter(String urlstring, BufferedOutputStream output) throws IOException { if (urlstring.length() > 0) { if (!urlstring.startsWith("http://") && !urlstring.startsWith("file:")) { urlstring = "http://" + urlstring; } if (proxyHost != null && proxyHost.length() != 0 && proxyPort != 0) { System.getProperties().setProperty("proxySet", "true"); System.getProperties().setProperty("proxyHost", proxyHost); System.getProperties().setProperty("proxyPort", "" + proxyPort); } PD4ML pd4ml = new PD4ML(); try { pd4ml.setPageSize(landscapeValue ? pd4ml.changePageOrientation(format) : format); } catch (Exception e) { e.printStackTrace(); } if (unitsValue.equals("mm")) { pd4ml.setPageInsetsMM(new Insets(topValue, leftValue, bottomValue, rightValue)); } else { pd4ml.setPageInsets(new Insets(topValue, leftValue, bottomValue, rightValue)); } pd4ml.setHtmlWidth(userSpaceWidth); pd4ml.render(urlstring, output); } }
我在一个servlet中使用的时候,通过url新建的访问链接,发现session无法和浏览器中的共享,无奈把一部分数据放到了application中,访问完了之后再删掉。 当然,这只是pd4ml的应用方式之一,感兴趣的朋友可以深入研究一下。
评论
5 楼
手心手背
2011-01-11
楼主中文乱码怎么解决啊!不胜感激!
4 楼
zdtwyjp
2010-07-19
你好呀!这两天在弄一个html转pdf的功能!头都弄晕了,试了好多插件都不行!
itext只能显示一种字符格式;
flying sauser纠错能力太差了,很多网页上的标签它不认识,显示不出来;
今天在网上搜到了PD4ML感觉还不错,比较合我的心意,不过还是有一个比较大的问题,哪就是如何处理中文问题?
LZ能否将处理中文的代码贴出来呀!
不胜感激呀!
itext只能显示一种字符格式;
flying sauser纠错能力太差了,很多网页上的标签它不认识,显示不出来;
今天在网上搜到了PD4ML感觉还不错,比较合我的心意,不过还是有一个比较大的问题,哪就是如何处理中文问题?
LZ能否将处理中文的代码贴出来呀!
不胜感激呀!
3 楼
cris_jxg
2009-08-21
谢谢,编码现在正确了
这个还是很不错的,只可惜不开源
这个还是很不错的,只可惜不开源
2 楼
daoger
2009-08-11
cris_jxg 写道
楼主中文怎么处理的,怎么发现中文乱码?
自己进行以下编码转化试试!
1 楼
cris_jxg
2009-08-11
楼主中文怎么处理的,怎么发现中文乱码?
发表评论
-
ubuntu14.04下编译安装Tora
2015-08-11 16:19 1164需预先安装oracle客户端;以下类库,有的可能需要提前安 ... -
ubuntu14.04下oracle客户端最小化安装
2015-08-11 16:04 1011在Oracle官网下载Oracle Instant Clien ... -
ubuntu14.04下编译安装QT
2015-08-11 16:03 14381. 首先配置一些编译Qt ... -
55种开源可视化数据分析工具
2015-07-22 14:50 0http://mp.weixin.qq.com/s?__bi ... -
响应式设计理念
2013-09-29 10:00 0概念 响应式Web设计(Responsive Web desi ... -
Liferay 使用随笔
2010-04-19 14:18 01.如何根据权限去除每一个portlet中右上角的选项。 关于 ... -
Liferay中ajax应用用户session超时
2010-03-26 09:31 3873基于Liferay Portal开发ajax应用时,如果长时间 ... -
Liferay portlet实例化配置
2009-11-10 09:06 4318在默认的情况下,一个p ... -
带checkbox的dhtmlxtree菜单树异步加载时的问题解决
2009-10-24 11:27 5904最近一直很忙,自己负责几个模块的设计开发,还有和其他服务接口的 ... -
JS代码示例
2009-10-21 14:23 22461.数组操作时的push var a = [],b = [ ... -
dhtmlxtree异步加载时的一个bug修正
2009-09-15 10:00 3774前面已经对dhtmlx的东西有所介绍,使用中也发现了不少bug ... -
Liferay中使用dhtmlxlayout在IE下的问题
2009-06-12 13:43 2059Liferay 中使用dhemtlx系列UI的时候,dhtml ... -
Liferay相关配置
2009-06-10 13:35 1219修改liferay中portlet的加载目录 前面 ... -
Spring JDBC对Oracle10g数据库操作时RowSet的问题
2009-05-19 08:56 3391使用Spring JDBC对Oracle10g进行数据库分页的 ... -
Dynamic Tables In JavaScript for IE and Firefox
2009-05-06 14:03 1665http://www.sweetvision.com/2007 ... -
liferay中对struts桥接处理后的response
2009-04-18 14:29 1789对于在liferay开发平台中 ... -
liferay开发小记---Struts,Spring,Hibernate架构
2009-04-07 11:11 6212liferay有自己的struts和spring扩展,有兴趣的 ... -
liferay开发小记---portlet文件构造
2009-04-03 17:09 3228书接上回,说说portlet的开发,每一个portlet就是对 ... -
liferay开发小记---开发环境的搭建
2009-04-02 13:42 3752用惯了MyEclipse,我的环境也是在它上面搭建的,试用过M ... -
跨域访问解决办法之java网络编程
2008-10-11 22:35 9158颓废了很长时间,还是心态问题! 项目中有不少地方需要跨域访 ...
相关推荐
Cascading Style Sheets (CSS) is a Web markup standard that allows Web designers to define the appearance and position of a Web page using special dynamic effects This book is the perfect beginner ...
Single page web applications are your next step: pushing UI rendering and business logic to the browser and communicating with the server only to synchronize data, they provide a smooth user ...
Learn the ins and outs of Responsive Web Design to make web pages look great on all devices NEW! Become familiar with the command line, Git, and other tools in the modern web developer’s toolkit NEW...
From the beginning, Building Web Applications with Flask shows you how to utilize Flask's concepts, extensions, and components to create engaging, full-featured web projects. You'll learn how to ...
Angular 5 Projects Learn to Build Single Page Web Applications Using 70+ Projects 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自...
date information on current browser support for CSS animations and transitions An introduction to manipulating web page objects in both 2D ...creating realistic animation and how they apply to web page designs
Author: Adam Freeman ISBN-10: 978-1-484200-86-5 Year: 2014 Pages: 688 Language: English File size: ...PDF Web API 2 is the latest evolution of Microsoft’s web services ...page applications to consume them.
A Web Component is well-encapsulated, keeping its internal structure separate from other page elements so they don't collide with the rest of your code. In Web Components in Action you'll learn to ...
NULL 博文链接:https://zhangxing119.iteye.com/blog/552400
You'll learn how to use Grunt to script the deployment of your web project, and use Angular to build a single-page app. You'll learn how to make content stand out with simple cross-browser styles; ...
Chapter 7, Implementing Routing and Navigation, describes how you can implement routing and navigation from scratch, and also how to integrate an existing library to fit into your isomorphic web app. ...
Referring the User to Browser-Specific Web Pages G Using Client Pull with Perl G Using Server Push with Perl G From Here G Chapter 7 Dynamic and Interactive HTML Content in Perl and CGI Creating ...
A mashup is a web page or application that combines data from two or more external online sources into an integrated experience. This book is your entryway to the world of mashups and Web 2.0. You ...
Serving as a tutorial and reference, this comprehensive resource explains the basic structure and necessary formatting to create a static (non-changing) and dynamic (changing) page on the Internet. ...
软件的操作非常简单,双击软件压缩包中的“wnvhtml2pdf.exe”,在“Enter Web Page URL or File Path”后面输入网页的地址,然后勾选“Convert to PDF with selectable text onvert to PDF with embedded image”前...
Select the content you wish to convert to Word directly from the PDF page. Formatting, styles, layout preserved. - WYSIWYG 内容提取。 转换从 PDF 文件选出的表格或图象。在 Word 或 Excel 中创建表格或...
Important new features such as the Canvas tag enable drawing directly onto the web page, the Audio tag allows sounds to be triggered and played from within your HTML code, the web sockets API brings ...
In Learning React , author Kirupa Chinnathambi brings his fresh, clear, and very personable writing style to help web developers new to React understand its fundamentals and how to use it to build ...
This book is for software developers who want to understand why C# 5 is designed the way it is and how to ...link on the book’s information page. Scroll down and click on the Source Code/Downloads tab.
Authors Alex Banks and Eve Porcello show you how to create UIs with this small JavaScript library that can deftly display data changes on large-scale, data-driven websites without page reloads....