mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[87956],{3905:function(t,e,n){n.d(e,{Zo:function(){return d},kt:function(){return c}});var r=n(67294);function a(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function p(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?p(Object(n),!0).forEach((function(e){a(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function o(t,e){if(null==t)return{};var n,r,a=function(t,e){if(null==t)return{};var n,r,a={},p=Object.keys(t);for(r=0;r<p.length;r++)n=p[r],e.indexOf(n)>=0||(a[n]=t[n]);return a}(t,e);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(t);for(r=0;r<p.length;r++)n=p[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(a[n]=t[n])}return a}var i=r.createContext({}),u=function(t){var e=r.useContext(i),n=e;return t&&(n="function"==typeof t?t(e):l(l({},e),t)),n},d=function(t){var e=u(t.components);return r.createElement(i.Provider,{value:e},t.children)},m={inlineCode:"code",wrapper:function(t){var e=t.children;return r.createElement(r.Fragment,{},e)}},s=r.forwardRef((function(t,e){var n=t.components,a=t.mdxType,p=t.originalType,i=t.parentName,d=o(t,["components","mdxType","originalType","parentName"]),s=u(n),c=a,k=s["".concat(i,".").concat(c)]||s[c]||m[c]||p;return n?r.createElement(k,l(l({ref:e},d),{},{components:n})):r.createElement(k,l({ref:e},d))}));function c(t,e){var n=arguments,a=e&&e.mdxType;if("string"==typeof t||a){var p=n.length,l=new Array(p);l[0]=s;var o={};for(var i in e)hasOwnProperty.call(e,i)&&(o[i]=e[i]);o.originalType=t,o.mdxType="string"==typeof t?t:a,l[1]=o;for(var u=2;u<p;u++)l[u]=n[u];return r.createElement.apply(null,l)}return r.createElement.apply(null,n)}s.displayName="MDXCreateElement"},78354:function(t,e,n){n.r(e),n.d(e,{frontMatter:function(){return o},contentTitle:function(){return i},metadata:function(){return u},toc:function(){return d},default:function(){return s}});var r=n(87462),a=n(63366),p=(n(67294),n(3905)),l=["components"],o={},i=void 0,u={unversionedId:"puppeteer.pdfoptions",id:"puppeteer.pdfoptions",isDocsHomePage:!1,title:"puppeteer.pdfoptions",description:"Home > puppeteer > PDFOptions",source:"@site/docs/puppeteer.pdfoptions.md",sourceDirName:".",slug:"/puppeteer.pdfoptions",permalink:"/puppeteer/docs/next/puppeteer.pdfoptions",editUrl:"https://github.com/facebook/puppeteer/edit/main/website/docs/puppeteer.pdfoptions.md",version:"current",frontMatter:{}},d=[{value:"PDFOptions interface",id:"pdfoptions-interface",children:[]},{value:"Properties",id:"properties",children:[]}],m={toc:d};function s(t){var e=t.components,n=(0,a.Z)(t,l);return(0,p.kt)("wrapper",(0,r.Z)({},m,n,{components:e,mdxType:"MDXLayout"}),(0,p.kt)("p",null,(0,p.kt)("a",{parentName:"p",href:"/puppeteer/docs/next/index"},"Home")," ",">"," ",(0,p.kt)("a",{parentName:"p",href:"/puppeteer/docs/next/puppeteer"},"puppeteer")," ",">"," ",(0,p.kt)("a",{parentName:"p",href:"/puppeteer/docs/next/puppeteer.pdfoptions"},"PDFOptions")),(0,p.kt)("h2",{id:"pdfoptions-interface"},"PDFOptions interface"),(0,p.kt)("p",null,"Valid options to configure PDF generation via ",(0,p.kt)("a",{parentName:"p",href:"/puppeteer/docs/next/puppeteer.page.pdf"},"Page.pdf()"),"."),(0,p.kt)("b",null,"Signature:"),(0,p.kt)("pre",null,(0,p.kt)("code",{parentName:"pre",className:"language-typescript"},"export interface PDFOptions \n")),(0,p.kt)("h2",{id:"properties"},"Properties"),(0,p.kt)("table",null,(0,p.kt)("thead",{parentName:"table"},(0,p.kt)("tr",{parentName:"thead"},(0,p.kt)("th",{parentName:"tr",align:null},"Property"),(0,p.kt)("th",{parentName:"tr",align:null},"Type"),(0,p.kt)("th",{parentName:"tr",align:null},"Description"))),(0,p.kt)("tbody",{parentName:"table"},(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.displayheaderfooter"},"displayHeaderFooter?")),(0,p.kt)("td",{parentName:"tr",align:null},"boolean"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Whether to show the header and footer.")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.footertemplate"},"footerTemplate?")),(0,p.kt)("td",{parentName:"tr",align:null},"string"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," HTML template for the print footer. Has the same constraints and support for special classes as ",(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.headertemplate"},"PDFOptions.headerTemplate"),".")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.format"},"format?")),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.paperformat"},"PaperFormat")),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)"))),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.headertemplate"},"headerTemplate?")),(0,p.kt)("td",{parentName:"tr",align:null},"string"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," HTML template for the print header. Should be valid HTML with the following classes used to inject values into them: - ",(0,p.kt)("code",null,"date")," formatted print date- ",(0,p.kt)("code",null,"title")," document title- ",(0,p.kt)("code",null,"url")," document location- ",(0,p.kt)("code",null,"pageNumber")," current page number- ",(0,p.kt)("code",null,"totalPages")," total pages in the document")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.height"},"height?")),(0,p.kt)("td",{parentName:"tr",align:null},"string ","|"," number"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Sets the height of paper. You can pass in a number or a string with a unit.")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.landscape"},"landscape?")),(0,p.kt)("td",{parentName:"tr",align:null},"boolean"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Whether to print in landscape orientation.")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.margin"},"margin?")),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfmargin"},"PDFMargin")),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Set the PDF margins.")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.omitbackground"},"omitBackground?")),(0,p.kt)("td",{parentName:"tr",align:null},"boolean"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Hides default white background and allows generating pdfs with transparency.")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.pageranges"},"pageRanges?")),(0,p.kt)("td",{parentName:"tr",align:null},"string"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Paper ranges to print, e.g. ",(0,p.kt)("code",null,"1-5, 8, 11-13"),".")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.path"},"path?")),(0,p.kt)("td",{parentName:"tr",align:null},"string"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," The path to save the file to.")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.prefercsspagesize"},"preferCSSPageSize?")),(0,p.kt)("td",{parentName:"tr",align:null},"boolean"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Give any CSS ",(0,p.kt)("code",null,"@page")," size declared in the page priority over what is declared in the ",(0,p.kt)("code",null,"width")," or ",(0,p.kt)("code",null,"height")," or ",(0,p.kt)("code",null,"format")," option.")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.printbackground"},"printBackground?")),(0,p.kt)("td",{parentName:"tr",align:null},"boolean"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Set to ",(0,p.kt)("code",null,"true")," to print background graphics.")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.scale"},"scale?")),(0,p.kt)("td",{parentName:"tr",align:null},"number"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Scales the rendering of the web page. Amount must be between ",(0,p.kt)("code",null,"0.1")," and ",(0,p.kt)("code",null,"2"),".")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.timeout"},"timeout?")),(0,p.kt)("td",{parentName:"tr",align:null},"number"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Timeout in milliseconds")),(0,p.kt)("tr",{parentName:"tbody"},(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/next/puppeteer.pdfoptions.width"},"width?")),(0,p.kt)("td",{parentName:"tr",align:null},"string ","|"," number"),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("i",null,"(Optional)")," Sets the width of paper. You can pass in a number or a string with a unit.")))))}s.isMDXComponent=!0}}]); |