Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from 0.3.5 -> 0.4.1 breaks image rendering #29

Closed
jperkelens opened this issue Apr 18, 2016 · 8 comments
Closed

Upgrade from 0.3.5 -> 0.4.1 breaks image rendering #29

jperkelens opened this issue Apr 18, 2016 · 8 comments

Comments

@jperkelens
Copy link

When we upgraded from 0.3.5 to 0.4.1, we are noticing that tags are failing to render properly.

We are using express 4 and an interesting quirk we noticed is that the pdf will render properly if we first pass the html fed to the phantom server in our express app. So, for example, in the code below, the image renders appropriately if we make a request to '/page' and then '/file' but not if we just call '/file'

var converter = require("phantom-html-to-pdf")()
app.get('/page', function(req, res, next) {
   var htmlForPdf = _.template(loadTemplate('pdf_report.html.erb'))()
   res.render('pdf', {pdf: htmlForPdf})
})

app.get('/file', function(req,res,next) {
   var htmlForPdf = _.template(loadTemplate('pdf_report.html.erb'))()
   converter({html: htmlForPdf}, function(err, file) {
     file.stream.pipe(res)
   })
}
@pofider
Copy link
Owner

pofider commented Apr 18, 2016

Hi,

could you try to print phantomjs output somewhere

var conversion = require("phantom-html-to-pdf")();
conversion({ html: "<h1>Hello World</h1>" }, function(err, pdf) {
  //print phantomjs output
  console.log(pdf.logs);
  console.log(pdf.numberOfPages);
  pdf.stream.pipe(res);
});

@romanmt
Copy link

romanmt commented May 5, 2016

I added the above logging....

res.log was empty.

converter({html: html, paperSize: { orientation: 'landscape' }}, (err, pdf) => {
  log.debug({logs: pdf.logs}, "pdf logs");
  log.debug({pages: pdf.numberOfPages}, "pdf number of pages");
  pdf.stream.pipe(res);
})
[2016-05-05T15:02:41.038Z] DEBUG: okdj-app/70305 on stravinsky.local: pdf logs (logtype=services)
[2016-05-05T15:02:41.039Z] DEBUG: okdj-app/70305 on stravinsky.local: pdf number of pages (logtype=services, pages=1)

@pofider
Copy link
Owner

pofider commented May 9, 2016

That is strange. The pdf.logs should be an array with at least 1 item. I double checked it and it is like that. I was using console.log..

Can you share your html?

@demsey2
Copy link

demsey2 commented Jun 8, 2016

We experienced a similar issue. Could you provide any update on that?

@pofider
Copy link
Owner

pofider commented Jun 8, 2016

@demsey2 Can you share the html on which it is breaking? We are using this component very heavily in jsreport without experiencing it.

Did you try using the latest release 0.4.2?

@demsey2
Copy link

demsey2 commented Jun 9, 2016

@pofider we use Flatdoc to generate html on fly from makrdown files, from time to time our doc file doesn't contain any images, I am going to try 0.4.2 and let you know

@pofider
Copy link
Owner

pofider commented Jun 9, 2016

@demsey2 Maybe you can also try to increase resourceTimeout #7 (comment)

@pofider
Copy link
Owner

pofider commented Sep 12, 2016

Closing due to inactivity. There was a very low resource loading timeout (1000ms) in one of the release which could cause missing images. This should be increased now. If you have further problem with images, please reopen.

@pofider pofider closed this as completed Sep 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants