puppeteer/assets/js/e629e34a.42779be5.js
release-please[bot] bbea692ddf deploy: 60699da691
2024-04-11 12:01:20 +00:00

2 lines
12 KiB
JavaScript

/*! For license information please see e629e34a.42779be5.js.LICENSE.txt */
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[42822],{87249:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>c,contentTitle:()=>t,default:()=>o,frontMatter:()=>s,metadata:()=>l,toc:()=>h});var r=d(85893),i=d(11151);const s={sidebar_label:"PDFOptions"},t="PDFOptions interface",l={id:"api/puppeteer.pdfoptions",title:"PDFOptions interface",description:"Valid options to configure PDF generation via Page.pdf().",source:"@site/../docs/api/puppeteer.pdfoptions.md",sourceDirName:"api",slug:"/api/puppeteer.pdfoptions",permalink:"/next/api/puppeteer.pdfoptions",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{sidebar_label:"PDFOptions"},sidebar:"api",previous:{title:"PDFMargin",permalink:"/next/api/puppeteer.pdfmargin"},next:{title:"Permission",permalink:"/next/api/puppeteer.permission"}},c={},h=[{value:"Signature:",id:"signature",level:4},{value:"Properties",id:"properties",level:2}];function p(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h4:"h4",li:"li",p:"p",pre:"pre",ul:"ul",...(0,i.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{id:"pdfoptions-interface",children:"PDFOptions interface"}),"\n",(0,r.jsxs)(n.p,{children:["Valid options to configure PDF generation via ",(0,r.jsx)(n.a,{href:"/next/api/puppeteer.page.pdf",children:"Page.pdf()"}),"."]}),"\n",(0,r.jsx)(n.h4,{id:"signature",children:"Signature:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-typescript",children:"export interface PDFOptions\n"})}),"\n",(0,r.jsx)(n.h2,{id:"properties",children:"Properties"}),"\n",(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)(n.p,{children:"Property"})}),(0,r.jsx)("th",{children:(0,r.jsx)(n.p,{children:"Modifiers"})}),(0,r.jsx)("th",{children:(0,r.jsx)(n.p,{children:"Type"})}),(0,r.jsx)("th",{children:(0,r.jsx)(n.p,{children:"Description"})}),(0,r.jsx)("th",{children:(0,r.jsx)(n.p,{children:"Default"})})]})}),(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"displayheaderfooter",children:"displayHeaderFooter"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"boolean"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Whether to show the header and footer."})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"false"})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"footertemplate",children:"footerTemplate"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"string"})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:["HTML template for the print footer. Has the same constraints and support for special classes as ",(0,r.jsx)(n.a,{href:"/next/api/puppeteer.pdfoptions#headertemplate",children:"PDFOptions.headerTemplate"}),"."]})}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"format",children:"format"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"/next/api/puppeteer.paperformat",children:"PaperFormat"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"letter"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"headertemplate",children:"headerTemplate"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"string"})}),(0,r.jsxs)("td",{children:[(0,r.jsx)(n.p,{children:"HTML template for the print header. Should be valid HTML with the following classes used to inject values into them:"}),(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"date"})," formatted print date"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"title"})," document title"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"url"})," document location"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"pageNumber"})," current page number"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"totalPages"})," total pages in the document"]}),"\n"]}),"\n"]})]}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"height",children:"height"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"string | number"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Sets the height of paper. You can pass in a number or a string with a unit."})}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"landscape",children:"landscape"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"boolean"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Whether to print in landscape orientation."})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"false"})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"margin",children:"margin"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.a,{href:"/next/api/puppeteer.pdfmargin",children:"PDFMargin"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Set the PDF margins."})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"undefined"})," no margins are set."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"omitbackground",children:"omitBackground"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"boolean"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Hides default white background and allows generating pdfs with transparency."})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"false"})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"outline",children:"outline"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"boolean"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Generate document outline."})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"false"})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"pageranges",children:"pageRanges"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"string"})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:["Paper ranges to print, e.g. ",(0,r.jsx)(n.code,{children:"1-5, 8, 11-13"}),"."]})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"The empty string, which means all pages are printed."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"path",children:"path"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"string"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"The path to save the file to."})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"undefined"}),", which means the PDF will not be written to disk."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"prefercsspagesize",children:"preferCSSPageSize"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"boolean"})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:["Give any CSS ",(0,r.jsx)(n.code,{children:"@page"})," size declared in the page priority over what is declared in the ",(0,r.jsx)(n.code,{children:"width"})," or ",(0,r.jsx)(n.code,{children:"height"})," or ",(0,r.jsx)(n.code,{children:"format"})," option."]})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"false"}),", which will scale the content to fit the paper size."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"printbackground",children:"printBackground"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"boolean"})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:["Set to ",(0,r.jsx)(n.code,{children:"true"})," to print background graphics."]})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"false"})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"scale",children:"scale"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"number"})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:["Scales the rendering of the web page. Amount must be between ",(0,r.jsx)(n.code,{children:"0.1"})," and ",(0,r.jsx)(n.code,{children:"2"}),"."]})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"1"})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"tagged",children:"tagged"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"boolean"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Generate tagged (accessible) PDF."})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"true"})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"timeout",children:"timeout"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"number"})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:["Timeout in milliseconds. Pass ",(0,r.jsx)(n.code,{children:"0"})," to disable timeout."]})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"30_000"})})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"width",children:"width"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"optional"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"string | number"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Sets the width of paper. You can pass in a number or a string with a unit."})}),(0,r.jsx)("td",{})]})]})]})]})}function o(e={}){const{wrapper:n}={...(0,i.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(p,{...e})}):p(e)}},75251:(e,n,d)=>{var r=d(67294),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function h(e,n,d){var r,s={},h=null,p=null;for(r in void 0!==d&&(h=""+d),void 0!==n.key&&(h=""+n.key),void 0!==n.ref&&(p=n.ref),n)t.call(n,r)&&!c.hasOwnProperty(r)&&(s[r]=n[r]);if(e&&e.defaultProps)for(r in n=e.defaultProps)void 0===s[r]&&(s[r]=n[r]);return{$$typeof:i,type:e,key:h,ref:p,props:s,_owner:l.current}}n.Fragment=s,n.jsx=h,n.jsxs=h},85893:(e,n,d)=>{e.exports=d(75251)},11151:(e,n,d)=>{d.d(n,{Z:()=>l,a:()=>t});var r=d(67294);const i={},s=r.createContext(i);function t(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:t(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]);