-
Notifications
You must be signed in to change notification settings - Fork 9k
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
render a pdf with an image. img disappeared #436
Comments
Could you please share the page you try to print? |
When I do the following the logo is not rendered: const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://google.com');
await page.pdf({path: './example.pdf', printBackground: true});
browser.close(); If I also add |
Your script yields the following pdf for me without the It could be that the logo is slow to load for you. Try navigating page with const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://google.com', {waitUntil: 'networkidle'}); // <== This should help
await page.pdf({path: './example.pdf', printBackground: true});
browser.close(); |
@aslushnikov Why was it closed? I am able to consistently reproduce the issue in puppeteer@0.10 and Chrome@60 in the print preview dialog under both Windows 10 and Mac. In my example I didn't notice but google.com redirected me to google.ru that has the issue. If I disable redirecting I get the same pdf as yours. It's actually bugged a bit too, note the missing 'apps' icon in the top right corner. Reproduce in puppeteer const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://google.ru'); // or 'https://google.de'
await page.screenshot({path: './example.png'});
await page.pdf({path: './example.pdf', printBackground: true}); // broken
await page.pdf({path: './example2.pdf', printBackground: true}); // fine
browser.close(); Screenshot renders fine, the 1st pdf has missing parts and the 2nd pdf is fine: Note: Adding Reproduce in Chrome Go to https://google.ru (or https://google.de), wait for the page to fully load and open the print dialog, a pdf in the preview has missing images. Changing settings and/or closing and opening the dialog again rerenders the pdf correctly. My print dialog settings:
|
@vlad-zhukov does your windows machine have screen dpi > 1? Here's the snippet that works for me: const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
await page.goto('https://google.ru', {waitUntil: 'networkidle'});
await page.setViewport({
width: 800,
height: 600,
deviceScaleFactor: 2,
});
await page.screenshot({path: './example.png'});
await page.pdf({path: './example.pdf', printBackground: true});
await page.pdf({path: './example2.pdf', printBackground: true});
browser.close();
})();
I can't repro this on Mac and Chrome 60.0.3112.113. The graphics always appears for me when the "print background" is checked and disappears when I uncheck. |
Thanks for looking into this. I've investigated a little more and set a simple example locally that reproduces this bug in Google Chrome, puppeteer and other Chromium-based browsers (Opera, Vivaldi). In short it fails to render images that are inside of a I am personally not affected by the issue and don't want to spend time reporting it to the Chromium bug tracker and all that stuff, however I can setup a GitHub repo with a reproduction if somebody else wants to push the issue further. Anyway in my opinion this issue should stay open for better visibility. |
I'd appreciate that. |
For anyone running into this issue, in my case, I had a self-signed SSL cert and by default Puppeteer won't load images for which there is an HTTPS error. So, for development purposes, I run Puppeteer like this: puppeteer.launch({ignoreHTTPSErrors: true})
.then(async browser => {
// ...
}); I will of course set |
I think this should be reopened. I have a case where a background image is not printed even with deviceScaleFactor: 2 - but it works if I generate the PDF a second time. The first time it always fails. I can only imagine that the issue is with the switch to the print-css. And then there is no time to load the image that matches the new styles. This is confirmed as |
If anybody ends up here because they couldn't get images to load in the |
0 The reason is ERR_UNSAFE_PORT! The port 6666 is considered unsafe. A full list of unsafe ports can be seen here: https://superuser.com/questions/188058/which-ports-are-considered-unsafe-by-chrome So just change the port of the webserver to something that is not on this list and everything works fine. |
Chromium version: 62.0.3188.0,
Nodejs version: v8.4.0,
puppeteer version: 0.9.0;
I rendered a pdf with
{ printBackground: true }
option, but the img not shown in the pdf.The text was updated successfully, but these errors were encountered: