pofider / phantom-html-to-pdf

Highly scalable html to pdf conversion using phantom workers
MIT License
159 stars 33 forks source link

Space at the end of PDF is of different color #40

Closed anirudhkkw closed 7 years ago

anirudhkkw commented 7 years ago
screen shot 2016-10-21 at 7 53 57 pm

Hi,

The footer in my PDFs are of a different color. Bluish tinge. Any way to solve this?

anirudhkkw commented 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

pofider commented 7 years ago

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?

anirudhkkw commented 7 years ago

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.

pofider commented 7 years ago

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.

anirudhkkw commented 7 years ago

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?

pofider commented 7 years ago

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.

anirudhkkw commented 7 years ago

I meant that the blue tinge at the end of the pdf is still present.

pofider commented 7 years ago

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'));
 })
anirudhkkw commented 7 years ago

so sorry. The body in html code had a different background color :P my bad :P