html to pdf转换客户端javascript与CSS支持

时间:2023-01-01 00:27:25

I tried to convert a complete html page to pdf with dynamic values but I can't .

我试图将完整的html页面转换为动态值的pdf,但我不能。

But I saw some API like jspdf but it is not useful for me. jspdf does not support CSS

但我看到了一些像jspdf这样的API,但它对我没用。 jspdf不支持CSS

is there any library available ?

有没有图书馆?

2 个解决方案

#1


0  

PhantomJS library would be helpful and easy thing to convert the HTML page to PDF or jpg/png format. It captures the current dom and converts the rendered content to PDF/png.

将HTML页面转换为PDF或jpg / png格式的PhantomJS库会很有帮助。它捕获当前的dom并将渲染的内容转换为PDF / png。

Sample Code

var page = require('webpage').create();
page.open('http://example.com/', function() {
  page.render('output.pdf');
  phantom.exit();
});

#2


0  

Same Problem here also. No Basic css support also for MrRio library. https://github.com/MrRio/jsPDF

这里也有同样的问题。 MrRio库也没有基本的CSS支持。 https://github.com/MrRio/jsPDF

But you may refer:

但你可以参考:

https://github.com/Flamenco/jsPDF

There is css support but there is issues with margin setting for pages.

有css支持,但页面的边距设置存在问题。

#1


0  

PhantomJS library would be helpful and easy thing to convert the HTML page to PDF or jpg/png format. It captures the current dom and converts the rendered content to PDF/png.

将HTML页面转换为PDF或jpg / png格式的PhantomJS库会很有帮助。它捕获当前的dom并将渲染的内容转换为PDF / png。

Sample Code

var page = require('webpage').create();
page.open('http://example.com/', function() {
  page.render('output.pdf');
  phantom.exit();
});

#2


0  

Same Problem here also. No Basic css support also for MrRio library. https://github.com/MrRio/jsPDF

这里也有同样的问题。 MrRio库也没有基本的CSS支持。 https://github.com/MrRio/jsPDF

But you may refer:

但你可以参考:

https://github.com/Flamenco/jsPDF

There is css support but there is issues with margin setting for pages.

有css支持,但页面的边距设置存在问题。