pd4ml html pdf 样式转pdf pdf中样式没有 而html pdf 样式中有样式 java

package com.blog.
import java.awt.I
import java.io.F
import java.io.IOE
import java.net.MalformedURLE
import java.net.URL;
import java.security.InvalidParameterE
import org.zefer.pd4ml.PD4C
import org.zefer.pd4ml.PD4ML;
public class GettingStarted1 {
protected int topValue = 10;
protected int leftValue = 20;
protected int rightValue = 10;
protected int bottomValue = 10;
protected int userSpaceWidth = 1300;
public static void main(String[] args) {
GettingStarted1 jt = new GettingStarted1();
jt.doConversion("/sample.htm", "c:/pd4ml.pdf");
} catch (Exception e) {
e.printStackTrace();
public void doConversion( String url, String outputPath )
throws InvalidParameterException, MalformedURLException, IOException {
File output = new File(outputPath);
java.io.FileOutputStream fos = new java.io.FileOutputStream(output);
PD4ML pd4ml = new PD4ML();
pd4ml.setHtmlWidth(userSpaceWidth); // set frame width of "virtual web browser"
// choose target paper format and "rotate" it to landscape orientation
pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.A4));
// define PDF page margins
pd4ml.setPageInsetsMM(new Insets(topValue, leftValue, bottomValue, rightValue));
// source HTML document also may have margins, could be suppressed this way
// (PD4ML *Pro* feature):
pd4ml.addStyle("BODY {margin: 0}", true);
// If built-in basic PDF fonts are not sufficient or
// if you need to output non-Latin texts,
// TTF embedding feature should help (PD4ML *Pro*)
pd4ml.useTTF("c:/windows/fonts", true);
pd4ml.render(new URL(url), fos); // actual document conversion from URL to file
fos.close();
System.out.println( outputPath + "\ndone." );下次自动登录
现在的位置:
& 综合 & 正文
pd4ml用来把html生成pdf的实例–需要pd4ml的jar包
package com.blog.
import java.awt.I
import java.io.F
import java.io.IOE
import java.net.MalformedURLE
import java.net.URL;
import java.security.InvalidParameterE
import org.zefer.pd4ml.PD4C
import org.zefer.pd4ml.PD4ML;
public class GettingStarted1 {
protected int topValue = 10;
protected int leftValue = 20;
protected int rightValue = 10;
protected int bottomValue = 10;
protected int userSpaceWidth = 1300;
public static void main(String[] args) {
GettingStarted1 jt = new GettingStarted1();
jt.doConversion("/sample.htm", "c:/pd4ml.pdf");
} catch (Exception e) {
e.printStackTrace();
public void doConversion( String url, String outputPath )
throws InvalidParameterException, MalformedURLException, IOException {
File output = new File(outputPath);
java.io.FileOutputStream fos = new java.io.FileOutputStream(output);
PD4ML pd4ml = new PD4ML();
pd4ml.setHtmlWidth(userSpaceWidth); // set frame width of "virtual web browser"
// choose target paper format and "rotate" it to landscape orientation
pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.A4));
// define PDF page margins
pd4ml.setPageInsetsMM(new Insets(topValue, leftValue, bottomValue, rightValue));
// source HTML document also may have margins, could be suppressed this way
// (PD4ML *Pro* feature):
pd4ml.addStyle("BODY {margin: 0}", true);
// If built-in basic PDF fonts are not sufficient or
// if you need to output non-Latin texts,
// TTF embedding feature should help (PD4ML *Pro*)
pd4ml.useTTF("c:/windows/fonts", true);
pd4ml.render(new URL(url), fos); // actual document conversion from URL to file
fos.close();
System.out.println( outputPath + "\ndone." );
&&&&推荐文章:
【上篇】【下篇】&>&pd4ml html转pdf
pd4ml html转pdf
上传大小:22.15MB
java通过pd4ml将html转成pdf,完美解决中文乱码和水印问题
综合评分:4(4位用户评分)
下载个数:125
{%username%}回复{%com_username%}{%time%}\
/*点击出现回复框*/
$(".respond_btn").on("click", function (e) {
$(this).parents(".rightLi").children(".respond_box").show();
e.stopPropagation();
$(".cancel_res").on("click", function (e) {
$(this).parents(".res_b").siblings(".res_area").val("");
$(this).parents(".respond_box").hide();
e.stopPropagation();
/*删除评论*/
$(".del_comment_c").on("click", function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_invalid/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parents(".conLi").remove();
alert(data.msg);
$(".res_btn").click(function (e) {
var q = $("#form1").serializeArray();
console.log(q);
var res_area_r = $.trim($(".res_area_r").val());
if (res_area_r == '') {
$(".res_text").css({color: "red"});
$.post("/index.php/comment/do_comment_reply/", q,
function (data) {
if (data.succ == 1) {
var $target,
evt = e || window.
$target = $(evt.target || evt.srcElement);
var $dd = $target.parents('dd');
var $wrapReply = $dd.find('.respond_box');
console.log($wrapReply);
var mess = $(".res_area_r").val();
var str = str.replace(/{%header%}/g, data.header)
.replace(/{%href%}/g, 'http://' + window.location.host + '/user/' + data.username)
.replace(/{%username%}/g, data.username)
.replace(/{%com_username%}/g, _username)
.replace(/{%time%}/g, data.time)
.replace(/{%id%}/g, data.id)
.replace(/{%mess%}/g, mess);
$dd.after(str);
$(".respond_box").hide();
$(".res_area_r").val("");
$(".res_area").val("");
$wrapReply.hide();
alert(data.msg);
}, "json");
/*删除回复*/
$(".rightLi").on("click",'.del_comment_r', function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_comment_del/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parent().parent().parent().parent().parent().remove();
$(e.target).parents('.res_list').remove()
alert(data.msg);
//填充回复
function KeyP(v) {
$(".res_area_r").val($.trim($(".res_area").val()));
评论共有3条
很不错,值得学习
不错,很好用
挺好的,但是代码中没有包括中文解决和样式加载,还好我机智,解决了。
审核通过送C币
FastJson、Gson、Jackson的JSON类库jar包合集
创建者:chenchunlin526
Openfire源码缺失的jar包列表
创建者:songxinfeng1989
精选6套分布式相关视频
创建者:love
上传者其他资源上传者专辑
《sql必知必会》epub版
materialize
Navicat Premium 11.0.19 中文绿色版
fatjar 新Eclipse版
exe4j 绿色版
开发技术热门标签
VIP会员动态
CSDN下载频道资源及相关规则调整公告V11.10
下载频道用户反馈专区
下载频道积分规则调整V1710.18
spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
pd4ml html转pdf
会员到期时间:
剩余下载个数:
剩余C币:593
剩余积分:0
为了良好体验,不建议使用迅雷下载
积分不足!
资源所需积分/C币
当前拥有积分
您可以选择
程序员的必选
绿色安全资源
资源所需积分/C币
当前拥有积分
当前拥有C币
(仅够下载10个资源)
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
你当前的下载分为234。
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可奖励20下载分
被举报人:
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:
pd4ml html转pdf

我要回帖

更多关于 itext html转pdf 样式 的文章

 

随机推荐