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([[55881],{3905:function(e,t,n){n.d(t,{Zo:function(){return d},kt:function(){return m}});var r=n(67294);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},p=Object.keys(e);for(r=0;r<p.length;r++)n=p[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);for(r=0;r<p.length;r++)n=p[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var i=r.createContext({}),u=function(e){var t=r.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},d=function(e){var t=u(e.components);return r.createElement(i.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},c=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,p=e.originalType,i=e.parentName,d=l(e,["components","mdxType","originalType","parentName"]),c=u(n),m=a,k=c["".concat(i,".").concat(m)]||c[m]||s[m]||p;return n?r.createElement(k,o(o({ref:t},d),{},{components:n})):r.createElement(k,o({ref:t},d))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var p=n.length,o=new Array(p);o[0]=c;var l={};for(var i in t)hasOwnProperty.call(t,i)&&(l[i]=t[i]);l.originalType=e,l.mdxType="string"==typeof e?e:a,o[1]=l;for(var u=2;u<p;u++)o[u]=n[u];return r.createElement.apply(null,o)}return r.createElement.apply(null,n)}c.displayName="MDXCreateElement"},55088:function(e,t,n){n.r(t),n.d(t,{frontMatter:function(){return l},contentTitle:function(){return i},metadata:function(){return u},toc:function(){return d},default:function(){return c}});var r=n(87462),a=n(63366),p=(n(67294),n(3905)),o=["components"],l={},i=void 0,u={unversionedId:"puppeteer.pdfoptions",id:"version-10.1.0/puppeteer.pdfoptions",isDocsHomePage:!1,title:"puppeteer.pdfoptions",description:"Home > puppeteer > PDFOptions",source:"@site/versioned_docs/version-10.1.0/puppeteer.pdfoptions.md",sourceDirName:".",slug:"/puppeteer.pdfoptions",permalink:"/puppeteer/docs/puppeteer.pdfoptions",editUrl:"https://github.com/facebook/puppeteer/edit/main/website/versioned_docs/version-10.1.0/puppeteer.pdfoptions.md",version:"10.1.0",frontMatter:{}},d=[{value:"PDFOptions interface",id:"pdfoptions-interface",children:[]},{value:"Properties",id:"properties",children:[]}],s={toc:d};function c(e){var t=e.components,n=(0,a.Z)(e,o);return(0,p.kt)("wrapper",(0,r.Z)({},s,n,{components:t,mdxType:"MDXLayout"}),(0,p.kt)("p",null,(0,p.kt)("a",{parentName:"p",href:"/puppeteer/docs/index"},"Home")," ",">"," ",(0,p.kt)("a",{parentName:"p",href:"/puppeteer/docs/puppeteer"},"puppeteer")," ",">"," ",(0,p.kt)("a",{parentName:"p",href:"/puppeteer/docs/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/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/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/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/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/puppeteer.pdfoptions.format"},"format?")),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/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/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/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/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/puppeteer.pdfoptions.margin"},"margin?")),(0,p.kt)("td",{parentName:"tr",align:null},(0,p.kt)("a",{parentName:"td",href:"/puppeteer/docs/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/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/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/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/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/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/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/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.")))))}c.isMDXComponent=!0}}]); |