GithubHelp home page GithubHelp logo

0xffan / chrome-pdf-printer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 33 KB

A cli app that print webpage as PDF via headless Chrome.

License: MIT License

JavaScript 100.00%
pdf pdf-generation chrome headless-chrome chromium headless-chromium html-pdf

chrome-pdf-printer's Introduction

chrome-pdf-printer

NPM npm

Print webpage as PDF via headless Chrome. This is a cli app build with html-pdf-chrome.

Usage

chrome-pdf-printer [options] --url <webpage_url> --save </path/to/pdf/filename.pdf>

Run chrome-pdf-printer --help to see all command options.

CompletionTrigger support

There are a few CompletionTrigger types in html-pdf-chrome that wait for something to occur before triggering PDF printing, see details here.

Timer, Element, Variable are supported in this project. The related command options are:

--printTrigger           # Trigger type: timer, element or variable
--triggerTimeout         # Milliseconds to wait for. Only effective for type Timer. Defaults to 7000ms.
--triggerElement         # Name of the DOM element to wait for, like 'div#myElement'. Only effective for type Element. Defaults to '#htmlPdfDone'.
--triggerVariable        # Name of the variable to wait for. Only effective for type Variable. Defaults to 'htmlPdfDone'.

Examples

# convert a webpage to pdf
chrome-pdf-printer \
  --url https://typo.sofi.sh \
  --save /home/username/test.pdf
# include background, and no margins
chrome-pdf-printer \
  --print-background \
  --margin-top 0 --margin-bottom 0 --margin-left 0 --margin-right 0 \
  --url https://typo.sofi.sh \
  --save /home/username/test.pdf
# set paper size
chrome-pdf-printer \
  --print-background \
  --paper-width 8.3 --paper-height 11.7 \
  --url https://typo.sofi.sh \
  --save /home/username/test.pdf
# set chrome flags
chrome-pdf-printer \
  --chrome-flags=--headless \
  --chrome-flags=--disable-gpu \
  --chrome-flags=--hide-scrollbars \
  --url https://typo.sofi.sh \
  --save /home/username/test.pdf

chrome-pdf-printer's People

Contributors

0xffan avatar vvjfan avatar

Watchers

 avatar

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.