Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Commands»How to Create PDF of Webpage Using Google Chrome Headless

    How to Create PDF of Webpage Using Google Chrome Headless

    By RahulJune 8, 20171 Min Read

    The latest Google Chrome 59 has included a new feature headless which provides functionality to run Google Chrome without UI. This allows users to use Google Chrome on the command line as well as scripts. This headless Google Chrome version also included the feature to create a PDF of any website using command line tool.

    Advertisement
    • How to Capture Screenshot of Webpage Using Google Chrome

    Requirements:

    You must be using Google Chrome 59 or later version. With the Google Chrome version 59, it’s only available for MAC OS and Linux users. Windows users still have to wait for some time.

    Create PDF with Google Chrome:

    Use the following google-chrome command with --print-to-pdf switch to create pdf of any web page. The output file will be created in the current directory with name output.pdf.

    $ google-chrome --headless --disable-gpu --print-to-pdf http://www.example.com/
    

    You can also specify output filename with location as --print-to-pdf=file1.pdf to create specific name.

    $ google-chrome --headless --disable-gpu --print-to-pdf=file1.pdf http://www.example.com/
    

    Reference:
    https://developers.google.com/web/updates/2017/04/headless-chrome

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    free Command in Linux (Check Memory Uses)

    A Practical Guide to Extracting Compressed Files in Linux

    TR Command in Linux: A Guide with Practical Examples

    TR Command in Linux: A Guide with Practical Examples

    View 3 Comments

    3 Comments

    1. Amol on July 21, 2021 11:57 am

      I want to add image in footer section can anybody guide me

      Reply
    2. elango on January 30, 2019 12:52 pm

      Hi rahul, how to do download pdfs in chrome headless using c#…

      Reply
    3. Upkar on July 11, 2017 8:01 pm

      Hi,

      thanks for the tutorial, it really works 🙂

      Just wanted to know if we can add some delay for Client rendered apps like angular and grab all rendering ?

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • A Comprehensive Look at the Simple Mail Transfer Protocol (SMTP)
    • Understanding Basic Git Workflow: Add, Commit, Push
    • The Difference Between Git Reset –soft, –mixed, and –hard
    • Understanding the Staging Area in Git’s Workflow
    • Python Function with Parameters, Return and Data Types
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.