最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - What HTML to PDF libraries handle javascript? - Stack Overflow

programmeradmin9浏览0评论

I'm trying to figure out how to generate a PDF from HTML that contains charts generated with the flot javascript library. Dompdf was my original conversion library but after adding flot charts it fails miserably. I've looked around SO (particularly at ) and googled for a while but can't seem to find any that explicitly provide javascript support. I'm working in PHP. I saw someone mention in that post that they had used php-wkhtmltox successfully in all cases but a chart generated by a different javascript library. Is that my only chance? I could possibly pay up to a couple hundred dollars if there is a mercial option available.

If this is something that really isn't possible with current libraries, what exactly is the challenge that makes it so much harder to convert html generated by javascript vs. normal html?

Thanks

I'm trying to figure out how to generate a PDF from HTML that contains charts generated with the flot javascript library. Dompdf was my original conversion library but after adding flot charts it fails miserably. I've looked around SO (particularly at https://stackoverflow./questions/3178448/list-of-html-to-pdf-converters) and googled for a while but can't seem to find any that explicitly provide javascript support. I'm working in PHP. I saw someone mention in that post that they had used php-wkhtmltox successfully in all cases but a chart generated by a different javascript library. Is that my only chance? I could possibly pay up to a couple hundred dollars if there is a mercial option available.

If this is something that really isn't possible with current libraries, what exactly is the challenge that makes it so much harder to convert html generated by javascript vs. normal html?

Thanks

Share Improve this question edited May 23, 2017 at 12:09 CommunityBot 11 silver badge asked Feb 1, 2011 at 4:09 Dave NovelliDave Novelli 2,2145 gold badges34 silver badges46 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 8

You can use wkhtmltopdf

Just extract it onto your server, run the mand (check out the manual here).

Thank you.

The Pdfcrowd HTML to PDF online API can run JavaScript. You can download a client library for PHP and give it a try.

It is a mercial SaaS solution, here is the docs: http://pdfcrowd./html-to-pdf-api/.

PDFPY

sudo npm i pdfpy

var pdfpy = require('pdfpy');

File

var pdfpy = require('pdfpy');

    var data = {
        //the key as to be same as below
        input: "./test.html",
        output: "./output.pdf"
    }
    pdfpy.file(data, function(err, res) {
        if(err) throw err

        if(res) console.log("success")
    });

URL

var pdfpy = require('pdfpy');

var data = {
    //the key as to be same as below
    input: "http://google.",
    output: "./output.pdf"
}
pdfpy.url(data, function(err, res) {
    if(err) throw err

    if(res) console.log("success")
});
发布评论

评论列表(0)

  1. 暂无评论