wkhtmltopdf missing SVG paths (Rendering)

后端 未结 2 2186
面向向阳花
面向向阳花 2021-02-19 02:41

I\'m using a image inside the HMTL code like here below:

2条回答
  •  鱼传尺愫
    2021-02-19 03:30

    So not a exact solution but a far better alternative now is to use a chrome in headless mode

    $ chrome --headless --disable-gpu --print-to-pdf test.html
    [0427/011400.636954:WARNING:dns_config_service_posix.cc(174)] dns_config has unhandled options!
    [0427/011400.638406:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
    [0427/011400.801881:INFO:headless_shell.cc(586)] Written to file output.pdf. 
    

    Also if you want better control on the process, you would use NodeJS and puppeteer

    const puppeteer = require('puppeteer');
    
    (async () => {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
      await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});
      await page.pdf({path: 'hn.pdf', format: 'A4'});
    
      await browser.close();
    })();
    

提交回复
热议问题