puppeteer: Links not rendering as links in PDF

Steps to reproduce

If I have a simple link in a page that I print to PDF, it gives the link text followed by the URL in parentheses instead of a clickable link. e.g. <a href="https://www.some-website.com">Link Text</a> would render as Link Text (https://www.some-website.com) It doesn’t fail like this on all links, but it does fail on simple links. I’m not sure what is the complication that makes it work. If I knew, I’d at least be able to generate links that worked on my internal webpage that I’m trying to print to PDF.

  • Puppeteer version: 1.16.0
  • Platform / OS version: Ubuntu 16.04.6 LTS
  • URLs (if applicable): nytimes.com is fine but myballard.com is not
  • Node.js version: 10.15.3

What steps will reproduce the problem?

const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({headless: true});
    const page = await browser.newPage();
    var url = process.argv[2];
    var outputFile = process.argv[3];
    try {
        await page.goto(url);
        await page.pdf({path: outputFile,
                        width: "8.5in",
                        height: "11in"});
        }
     catch (error) {
         console.log(error)
        }
     await browser.close();
     }
)();

Bad links show up in this generated pdf: nodejs simple-print-url-to-pdf.js https://www.myballard.com bad_link_example.pdf

Good links show up in this generated pdf: nodejs simple-print-url-to-pdf.js https://www.nytimes.com good_link_example.pdf

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (2 by maintainers)

Most upvoted comments

@JulieGoldberg Can you share your work-around ?

Sorry, I didn’t notice the suggestion to post elsewhere. https://bugs.chromium.org/p/chromium/issues/detail?id=984040

I found a work-around that works well enough but I’d really like to get this working properly, so I can format my PDF better.

hahah actually no need change anything u just put a href link it will able generate link in pdf alrdy… hahah the library is amazing keep it up pls do more enhancement make it better…