如何将HTML和CSS转换为pdf格式? [英] How can I do HTML and CSS to pdf format?

查看:98
本文介绍了如何将HTML和CSS转换为pdf格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从html下载pdf时,我没有正确地在PDF文件中获得布局。



我尝试了什么:



我用这个脚本从html下载PDF:





var downloadPDFnew = function(){

var htmlPdf = $('#form-2')。html();

$('#form-2') .find('input')。each(function(r){

var vl = $(this).val();

console.log(vl);

$(this).parent('。drive_name')。append(< p>+ vl +< / p>);

$(这个).remove();

});

DocRaptor.createAndDownloadDoc(YOUR_API_KEY_HERE,{

test:true,// test文件是免费的,但有水印

类型:pdf,

document_content:$('#form-2')。html(),

})



$('#form-2')。html(htmlPdf);

doc.setFontSize(40);

}

When i download the pdf from html i don't get layout properly in PDF file.

What I have tried:

I have used this script for Download the PDF from html:


var downloadPDFnew = function() {
var htmlPdf = $('#form-2').html();
$('#form-2').find('input').each(function(r){
var vl = $(this).val();
console.log(vl);
$(this).parent('.drive_name').append("<p>"+vl+"</p>" );
$(this).remove();
});
DocRaptor.createAndDownloadDoc("YOUR_API_KEY_HERE", {
test: true, // test documents are free, but watermarked
type: "pdf",
document_content: $('#form-2').html(),
})

$('#form-2').html(htmlPdf);
doc.setFontSize(40);
}

推荐答案

('#form-2')。html();
('#form-2').html();


('#form- 2')。find('input')。each(function(r){

var vl =
('#form-2').find('input').each(function(r){
var vl =


(this).val();

console.log(vl);
(this).val();
console.log(vl);


这篇关于如何将HTML和CSS转换为pdf格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆