additional options in Chrome headless print-to-pdf

后端 未结 2 1890
情歌与酒
情歌与酒 2020-12-13 18:34

I need help one more time. I am trying to print a page to pdf using headless feature of the chrome. However, header and footer is present in the pdf. I found that this optio

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 19:11

    "/path/to/google-chrome" : This is the path of Google Chrome.

    '--headless' : Chrome browser in a headless environment without the full browser UI

    '--run-all-compositor-stages-before-draw' : It Prevents the Pdf Creation Before all the data is rendered(After all data is rendered the pdf will be created).

    '--virtual-time-budget = x: It Delays the Process of creation of Pdf, here x will be the miliseconds.

    '--print-to-pdf' : This Flag creates the pdf of the given Url.

    URL : The url of webpage.

    PDF Page Formatting (Using CSS) Adding this(to css files):

     @media print {
                @page { margin: 0mm 0mm 0mm 0mm;
                size:8in 9.5in;
                }
                }
    

    The Above CSS code has no effect on the Webpage Rendering,But effect on the formatting of page in PDF only.

提交回复
热议问题