Closed anirudhkkw closed 7 years ago
conversion({
url: URL,
fitToPage: true,
viewportSize: {
width: 640
},
format: {
quality: 100
},
paperSize: {
margin: "0cm"
},
phantomPath: require("phantomjs-prebuilt").path
}, function (err, data){
res.setHeader('Content-type', 'application/pdf');
data.stream.pipe(res);
})
These are my current settings
Interesting, never seen this.
Which os you have? Did you install libfontconfig if it is linux? Does it also happen if you turn off fit to page? Does it also happen if you pass html instead of url?
im on ubuntu 16.04.01 Yes, I have install libfontconfig. Yes, it still occurs if I pass false for fitToPage. I haven't tried the HTML yet. Could that be the reason? I really need the URL though.
I'm just suggesting what to try, I don't know if it actually helps...
You would get better support in phantomjs repository. This package only wraps phantomjs and make it easy to use in scale fashion.
Hi,
request(URL, function(error, response, data) {
conversion({
html: data,
fitToPage: true,
viewportSize: {
width: 640
},
format: {
quality: 100
},
paperSize: {
margin: "0cm"
},
phantomPath: require("phantomjs-prebuilt").path
}, function (err, data){
res.setHeader('Content-type', 'application/pdf');
data.stream.pipe(res);
})
});
I tried doing this. First request the url and get the HTML and then pass HTML to the PDF generator but to no avail. Am I doing something wrong?
but to no avail
What do you mean?
The code looks fine. You will likely not get css and js applied because of relative links, but you get at lease more idea if the problem is with particular page css and js or it is a server font issue.
I meant that the blue tinge at the end of the pdf is still present.
Ah ok, the blue part is there also with a "Hello world" html right? There is likely something wrong with your ubuntu packages, unfortunately I've no clue how to trouble shoot it. Just to make sure, I've tried the following code on ubuntu 16.04 and I've no blue part there
var conversion = require('phantom-html-to-pdf')()
conversion({
html: 'hello',
fitToPage: true,
viewportSize: {
width: 640
},
format: {
quality: 100
},
paperSize: {
margin: "0cm"
},
phantomPath: require("phantomjs-prebuilt").path
}, function (err, data){
data.stream.pipe(require('fs').createWriteStream('out.pdf'));
})
so sorry. The body in html code had a different background color :P my bad :P
Hi,
The footer in my PDFs are of a different color. Bluish tinge. Any way to solve this?