puppeteer/assets/js/d3609b62.b3518e72.js
release-please[bot] 53572b57ec deploy: 73ca94fe66
2023-03-14 11:00:36 +00:00

1 line
13 KiB
JavaScript

"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[33440],{3905:(t,e,a)=>{a.d(e,{Zo:()=>u,kt:()=>k});var n=a(67294);function r(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function p(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.push.apply(a,n)}return a}function l(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?p(Object(a),!0).forEach((function(e){r(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):p(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}function i(t,e){if(null==t)return{};var a,n,r=function(t,e){if(null==t)return{};var a,n,r={},p=Object.keys(t);for(n=0;n<p.length;n++)a=p[n],e.indexOf(a)>=0||(r[a]=t[a]);return r}(t,e);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(t);for(n=0;n<p.length;n++)a=p[n],e.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(t,a)&&(r[a]=t[a])}return r}var o=n.createContext({}),d=function(t){var e=n.useContext(o),a=e;return t&&(a="function"==typeof t?t(e):l(l({},e),t)),a},u=function(t){var e=d(t.components);return n.createElement(o.Provider,{value:e},t.children)},m={inlineCode:"code",wrapper:function(t){var e=t.children;return n.createElement(n.Fragment,{},e)}},s=n.forwardRef((function(t,e){var a=t.components,r=t.mdxType,p=t.originalType,o=t.parentName,u=i(t,["components","mdxType","originalType","parentName"]),s=d(a),k=r,g=s["".concat(o,".").concat(k)]||s[k]||m[k]||p;return a?n.createElement(g,l(l({ref:e},u),{},{components:a})):n.createElement(g,l({ref:e},u))}));function k(t,e){var a=arguments,r=e&&e.mdxType;if("string"==typeof t||r){var p=a.length,l=new Array(p);l[0]=s;var i={};for(var o in e)hasOwnProperty.call(e,o)&&(i[o]=e[o]);i.originalType=t,i.mdxType="string"==typeof t?t:r,l[1]=i;for(var d=2;d<p;d++)l[d]=a[d];return n.createElement.apply(null,l)}return n.createElement.apply(null,a)}s.displayName="MDXCreateElement"},61345:(t,e,a)=>{a.r(e),a.d(e,{assets:()=>d,contentTitle:()=>i,default:()=>s,frontMatter:()=>l,metadata:()=>o,toc:()=>u});a(67294);var n=a(3905);function r(){return r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},r.apply(this,arguments)}function p(t,e){if(null==t)return{};var a,n,r=function(t,e){if(null==t)return{};var a,n,r={},p=Object.keys(t);for(n=0;n<p.length;n++)a=p[n],e.indexOf(a)>=0||(r[a]=t[a]);return r}(t,e);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(t);for(n=0;n<p.length;n++)a=p[n],e.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(t,a)&&(r[a]=t[a])}return r}const l={sidebar_label:"PDFOptions"},i="PDFOptions interface",o={unversionedId:"api/puppeteer.pdfoptions",id:"version-19.7.5/api/puppeteer.pdfoptions",title:"PDFOptions interface",description:"Valid options to configure PDF generation via Page.pdf().",source:"@site/versioned_docs/version-19.7.5/api/puppeteer.pdfoptions.md",sourceDirName:"api",slug:"/api/puppeteer.pdfoptions",permalink:"/api/puppeteer.pdfoptions",draft:!1,tags:[],version:"19.7.5",frontMatter:{sidebar_label:"PDFOptions"},sidebar:"api",previous:{title:"PDFMargin.top",permalink:"/api/puppeteer.pdfmargin.top"},next:{title:"PDFOptions.displayHeaderFooter",permalink:"/api/puppeteer.pdfoptions.displayheaderfooter"}},d={},u=[{value:"Signature:",id:"signature",level:4},{value:"Properties",id:"properties",level:2}],m={toc:u};function s(t){var{components:e}=t,a=p(t,["components"]);return(0,n.kt)("wrapper",r({},m,a,{components:e,mdxType:"MDXLayout"}),(0,n.kt)("h1",r({},{id:"pdfoptions-interface"}),"PDFOptions interface"),(0,n.kt)("p",null,"Valid options to configure PDF generation via ",(0,n.kt)("a",r({parentName:"p"},{href:"/api/puppeteer.page.pdf"}),"Page.pdf()"),"."),(0,n.kt)("h4",r({},{id:"signature"}),"Signature:"),(0,n.kt)("pre",null,(0,n.kt)("code",r({parentName:"pre"},{className:"language-typescript"}),"export interface PDFOptions\n")),(0,n.kt)("h2",r({},{id:"properties"}),"Properties"),(0,n.kt)("table",null,(0,n.kt)("thead",{parentName:"table"},(0,n.kt)("tr",{parentName:"thead"},(0,n.kt)("th",r({parentName:"tr"},{align:null}),"Property"),(0,n.kt)("th",r({parentName:"tr"},{align:null}),"Modifiers"),(0,n.kt)("th",r({parentName:"tr"},{align:null}),"Type"),(0,n.kt)("th",r({parentName:"tr"},{align:null}),"Description"),(0,n.kt)("th",r({parentName:"tr"},{align:null}),"Default"))),(0,n.kt)("tbody",{parentName:"table"},(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.displayheaderfooter"}),"displayHeaderFooter?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"boolean"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Whether to show the header and footer."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"false")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.footertemplate"}),"footerTemplate?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"string"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," HTML template for the print footer. Has the same constraints and support for special classes as ",(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.headertemplate"}),"PDFOptions.headerTemplate"),"."),(0,n.kt)("td",r({parentName:"tr"},{align:null}))),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.format"}),"format?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.paperformat"}),"PaperFormat")),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("code",null,"letter"),".")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.headertemplate"}),"headerTemplate?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"string"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("p",null,(0,n.kt)("em",{parentName:"td"},"(Optional)")," HTML template for the print header. Should be valid HTML with the following classes used to inject values into them:"),(0,n.kt)("p",null,"- ",(0,n.kt)("code",null,"date")," formatted print date"),(0,n.kt)("p",null,"- ",(0,n.kt)("code",null,"title")," document title"),(0,n.kt)("p",null,"- ",(0,n.kt)("code",null,"url")," document location"),(0,n.kt)("p",null,"- ",(0,n.kt)("code",null,"pageNumber")," current page number"),(0,n.kt)("p",null,"- ",(0,n.kt)("code",null,"totalPages")," total pages in the document")),(0,n.kt)("td",r({parentName:"tr"},{align:null}))),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.height"}),"height?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"string ","|"," number"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Sets the height of paper. You can pass in a number or a string with a unit."),(0,n.kt)("td",r({parentName:"tr"},{align:null}))),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.landscape"}),"landscape?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"boolean"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Whether to print in landscape orientation."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"= false")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.margin"}),"margin?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfmargin"}),"PDFMargin")),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Set the PDF margins."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"no margins are set.")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.omitbackground"}),"omitBackground?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"boolean"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Hides default white background and allows generating pdfs with transparency."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"false")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.pageranges"}),"pageRanges?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"string"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Paper ranges to print, e.g. ",(0,n.kt)("code",null,"1-5, 8, 11-13"),"."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"The empty string, which means all pages are printed.")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.path"}),"path?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"string"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," The path to save the file to."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"the empty string, which means the PDF will not be written to disk.")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.prefercsspagesize"}),"preferCSSPageSize?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"boolean"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Give any CSS ",(0,n.kt)("code",null,"@page")," size declared in the page priority over what is declared in the ",(0,n.kt)("code",null,"width")," or ",(0,n.kt)("code",null,"height")," or ",(0,n.kt)("code",null,"format")," option."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("code",null,"false"),", which will scale the content to fit the paper size.")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.printbackground"}),"printBackground?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"boolean"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Set to ",(0,n.kt)("code",null,"true")," to print background graphics."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"false")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.scale"}),"scale?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"number"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Scales the rendering of the web page. Amount must be between ",(0,n.kt)("code",null,"0.1")," and ",(0,n.kt)("code",null,"2"),"."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"1")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.timeout"}),"timeout?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"number"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Timeout in milliseconds. Pass ",(0,n.kt)("code",null,"0")," to disable timeout."),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"30000")),(0,n.kt)("tr",{parentName:"tbody"},(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("a",r({parentName:"td"},{href:"/api/puppeteer.pdfoptions.width"}),"width?")),(0,n.kt)("td",r({parentName:"tr"},{align:null})),(0,n.kt)("td",r({parentName:"tr"},{align:null}),"string ","|"," number"),(0,n.kt)("td",r({parentName:"tr"},{align:null}),(0,n.kt)("em",{parentName:"td"},"(Optional)")," Sets the width of paper. You can pass in a number or a string with a unit."),(0,n.kt)("td",r({parentName:"tr"},{align:null}))))))}s.isMDXComponent=!0}}]);