Giter Site home page Giter Site logo

jarvusinnovations / puppeteer-cli Goto Github PK

View Code? Open in Web Editor NEW
53.0 6.0 24.0 80 KB

A general command-line wrapper for puppeteer. Currently only supports one command—`print`—to render a local/or remote HTML file to PDF. Aims to be a easy replacement for the deprecated wkhtmltopdf.

License: MIT License

JavaScript 100.00%

puppeteer-cli's Issues

Source fetching

What's your thought about having a command like:

puppeteer source https://github.com

Which will just return the HTML source as text for that page?
I'm happy to create a PR for this but first wanted to check what your idea was about this feature.

External imported fonts - randomly not rendered

My page import fonts from adobe cdn. And they are randomly not render correctly. Approx 1 of 10 rendered fonts are not render at all or are used default fallback fonts. I struggle with this and i found solution.

Before render pdf i wait for fonts ready.

  //....
  // Output options if in debug mode
  if (cli.debug) {
    console.log(options);
  }
  await page.evaluateHandle('document.fonts.ready'); // add this line
  await page.pdf(options);

getting a punch of garbage

sprunge.us/sMiEhK

$ npx puppeteer-cli print https://www.ft.com/content/2bbedfde-c9da-4bc6-b2e6-af0698240851

I can't install it...Why???

sudo npm install -g puppeteer-cli

/usr/local/bin/puppeteer -> /usr/local/lib/node_modules/puppeteer-cli/index.js

[email protected] install /usr/local/lib/node_modules/puppeteer-cli/node_modules/puppeteer
node install.js

ERROR: Failed to download Chromium r686378! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/puppeteer-cli/node_modules/puppeteer/.local-chromium'
-- ASYNC --
at BrowserFetcher. (/usr/local/lib/node_modules/puppeteer-cli/node_modules/puppeteer/lib/helper.js:111:15)
at Object. (/usr/local/lib/node_modules/puppeteer-cli/node_modules/puppeteer/install.js:64:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path:
'/usr/local/lib/node_modules/puppeteer-cli/node_modules/puppeteer/.local-chromium' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/martin/.npm/_logs/2020-01-11T22_27_48_870Z-debug.log

Invalid regular expression when using --viewport=1920x1080

I am receiving an invalid regular expression error when using the puppeteer-cli 1.5.1 on ubuntu 18.04 LTS.

The result is listed below, why would this error trigger?

Failed to take screenshot: SyntaxError: Invalid regular expression: /^(?<width>\d+)[xX](?<height>\d+)$/: Invalid group at screenshot (/usr/local/lib/node_modules/puppeteer-cli/index.js:153:43) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)

Cookie issue

When building the cookies the code incorrectly uses the spread operator which causes the passed cooke string to not be read correctly.

The line return [...cookie].map(cookieString => { forces the cookies to be read one character at a time which is incorrect.

Changing the line to return [cookie].map(cookieString => { fixes this problem.

I would do a PR but I don't know how!

GitHub "about" text is out of date

Current text:

A general command-line wrapper for puppeteer. Currently only supports one command—print—to render a local/or remote HTML file to PDF. Aims to be a easy replacement for the deprecated wkhtmltopdf.

JarvusInnovations_puppeteer-cli__A_general_command-line_wrapper_for_puppeteer__Currently_only_supports_one_command—`print`—to_render_a_local_or_remote_HTML_file_to_PDF__Aims_to_be_a_easy_replacement_for_the_deprecated_wkhtmltopdf_

This is no longer accurate - the screenshot command can output to PNG.

Nuev

team-review-requested:[TEAMNAME

Header and Footer doesn't Show

Hi!

I'm trying to use the headerTemplate and footerTemplate option, like in the puppeteer documentation, but nothing seems to appear in my print. Am I missing something?

const headerTemplate = Header 1; const footerTemplate = Footer;

const buffer = await page.pdf({ path: filePath || null, format: argv.format, landscape: argv.landscape, printBackground: argv.background, margin: { top: argv.marginTop, right: argv.marginRight, bottom: argv.marginBottom, left: argv.marginLeft }, displayHeaderFooter: true, headerTemplate: headerTemplate, footerTemplate: footerTemplate, pageRanges: pageRangeArray[index] });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.