@@ -998,6 +998,12 @@ <h3>Endpoints</h3>
998998 < td > /session/{< var > session id</ var > }/element/{< var > element id</ var > }/screenshot</ td >
999999 < td > < a > Take Element Screenshot</ a > </ td >
10001000 </ tr >
1001+
1002+ < tr >
1003+ < td > POST</ td >
1004+ < td > /session/{< var > session id</ var > }/print</ td >
1005+ < td > < a > Print Page</ a > </ td >
1006+ </ tr >
10011007</ table >
10021008</ section > <!-- /Endpoints -->
10031009
@@ -9073,6 +9079,267 @@ <h3><dfn>Take Element Screenshot</dfn></h3>
90739079</ section > <!-- /Take Element Screenshot -->
90749080</ section > <!-- /Screen capture -->
90759081
9082+ < section >
9083+ < h2 > Print</ h2 >
9084+
9085+ < p > The print functions are a mechanism to render the document to a
9086+ paginated format. It is returned to the < a > local end</ a > as a Base64
9087+ encoded string containing a PDF representation of the paginated
9088+ document.
9089+
9090+ < p class =note >
9091+ For historical reasons, all dimensions relating to the printed output
9092+ are specified in inches.
9093+
9094+ < p > When required to < dfn > parse a page range</ dfn > with
9095+ arguments < var > pageRanges</ var > and < var > totalPages</ var > , an
9096+ implementation must:
9097+
9098+ < ol >
9099+ < li > Let < var > pages</ var > be an empty < a > Set</ a >
9100+
9101+ < li > For each < var > range</ var > in < var > pageRanges</ var > , run the
9102+ following steps:
9103+ < ol >
9104+ < li > If < var > range</ var > is not either a < a > Number</ a > or
9105+ a < a > String</ a > , return < a > error</ a > with < a > error
9106+ code</ a > < a > invalid argument</ a > .
9107+
9108+ < li > < p > If < var > range</ var > is a < a > Number</ a > :
9109+ < ol >
9110+ < li > If < var > range</ var > is not an integer or is less than 0,
9111+ return < a > error</ a > with < a > error code</ a > < a > invalid
9112+ argument</ a >
9113+
9114+ < li > Append < var > range</ var > to < var > pages</ var >
9115+ </ ol >
9116+ < p > Otherwise:
9117+ < ol >
9118+ < li > Let < var > rangeParts</ var > be the result of
9119+ splitting < var > range</ var > on a "< code > -</ code > " character.
9120+
9121+ < li > If < var > rangeParts</ var > has fewer than 1 or more than 2
9122+ elements, return < a > error</ a > with < a > error code</ a > < a > invalid
9123+ argument</ a > .
9124+
9125+ < li > If rangeParts has one element, append the result
9126+ of < a > trying</ a > to < a > parse as an integer</ a > the first
9127+ element of < var > rangeParts</ var >
9128+ to < var > pages</ var > .
9129+ < p > Otherwise:
9130+ < ol >
9131+ < li > If the first element of < var > rangeParts</ var >
9132+ is < a > equivalent to an empty string</ a > ,
9133+ let < var > lowerBound</ var >
9134+ be < code > 1</ code > . Otherwise
9135+ let < var > lowerBound</ var > be the result
9136+ of < a > trying</ a > to < a > parse as an integer</ a > the
9137+ first element of < var > rangeParts</ var > .
9138+
9139+ < li > If the second element of < var > rangeParts</ var >
9140+ is < a > equivalent to an empty string</ a >
9141+ let < var > upperBound</ var >
9142+ be < var > totalPages</ var > . Otherwise
9143+ let < var > upperBound</ var > be the result
9144+ of < a > trying</ a > to < a > parse as an integer</ a > the
9145+ second element of < var > rangeParts</ var > .
9146+
9147+ < li > If < var > lowerBound</ var > is greater
9148+ than < var > upperBound</ var > , return < a > error</ a >
9149+ with < a > error code</ a > < a > invalid argument</ a > .
9150+
9151+ < li > Append all integers in the inclusive
9152+ range < var > lowerBound</ var > to < var > upperBound</ var >
9153+ to < var > pages</ var >
9154+ </ ol >
9155+ </ ol >
9156+ < li > Return < a > success</ a > with data < var > pages</ var > .
9157+ </ ol >
9158+
9159+ < p > A < a > String</ a > is < dfn > equivalent to an empty string</ dfn > if it
9160+ has zero length after removing all < a > whitespace</ a > characters.
9161+
9162+ < p > When required to < dfn > parse as an integer</ dfn > with
9163+ argument < var > input</ var > an implementation must:
9164+
9165+ < ol >
9166+ < li > Let < var > stripped</ var > be the result of stripping all leading
9167+ and trailing < a > whitespace</ a > characters from < var > input</ var > .
9168+
9169+ < li > If < var > stripped</ var > has zero length, return < a > error</ a > with
9170+ status < a > invalid argument</ a > .
9171+
9172+ < li > If < var > stripped</ var > contains any characters outside the
9173+ range < code > U+0030</ code > - < code > U+0039</ code > (i.e. 0 - 9)
9174+ inclusive, return < a > error</ a > with status < a > invalid argument</ a > .
9175+
9176+ < li > Let < var > output</ var > be the result of calling < a > parseInt</ a >
9177+ with string < var > stripped</ var > and radix < code > 10</ code > .
9178+
9179+ < li > Return < a > success</ a > with data < var > output</ var > .
9180+ </ ol >
9181+
9182+ < section >
9183+ < h3 > < dfn > Print Page</ dfn > </ h3 >
9184+
9185+ < table class ="simple jsoncommand ">
9186+ < tr >
9187+ < th > HTTP Method
9188+ < th > URI Template
9189+ </ tr >
9190+ < tr >
9191+ < td > POST
9192+ < td > /session/{< var > session id</ var > }/print
9193+ </ tr >
9194+ </ table >
9195+
9196+ < p > The < a > remote end steps</ a > are:
9197+
9198+ < ol >
9199+ < li > < p > If the < a > current top-level browsing context</ a > is < a > no longer open</ a > ,
9200+ return < a > error</ a > with < a > error code</ a > < a > no such window</ a > .
9201+
9202+ < li > < p > < a > Handle any user prompts</ a > and return its value if it is an < a > error</ a > .
9203+
9204+ < li > < p > Let < var > orientation</ var > be the result of < a > getting a
9205+ property with default</ a > named < code > orientation</ code > and with
9206+ default "< code > portrait</ code > " from the < var > parameters</ var >
9207+ argument.
9208+
9209+ < li > < p > If < var > orientation</ var > is not a < a > String</ a > or does not
9210+ have one of the values "< code > landscape</ code > " or
9211+ "< code > portrait</ code > ", return < a > error</ a > with < a > error
9212+ code</ a > < a > invalid argument</ a > .
9213+
9214+ < li > < p > Let < var > scale</ var > be the result of < a > getting a
9215+ property with default</ a > named < code > scale</ code > and with
9216+ default < code > 1</ code > from the < var > parameters</ var > argument.
9217+
9218+ < li > < p > If < var > scale</ var > is not a < a > Number</ a > , or is less
9219+ than < code > 0.1</ code > or greater than < code > 2</ code >
9220+ return < a > error</ a > with < a > error code</ a > < a > invalid argument</ a > .
9221+
9222+ < li > < p > Let < var > background</ var > be the result of < a > getting a
9223+ property with default</ a > named < code > background</ code > and with
9224+ default < code > false</ code > from the < var > parameters</ var > argument.
9225+
9226+ < li > < p > If < var > background</ var > is not a < a > Boolean</ a >
9227+ return < a > error</ a > with < a > error code</ a > < a > invalid argument</ a > .
9228+
9229+ < li > < p > Let < var > page</ var > be the result of < a > getting a property
9230+ with default</ a > named < code > page</ code > and with a default of an
9231+ empty < a > Object</ a > from the < var > parameters</ var > argument.
9232+
9233+ < li > < p > Let < var > pageWidth</ var > be the result of < a > getting a
9234+ property with default</ a > named < code > width</ code > and with a
9235+ default of < code > 8.5</ code > from < var > page</ var > .
9236+
9237+ < li > < p > Let < var > pageHeight</ var > be the result of < a > getting a
9238+ property with default</ a > named < code > width</ code > and with a
9239+ default of < code > 11</ code > from < var > page</ var > .
9240+
9241+ < li > < p > If either of < var > pageWidth</ var > or < var > pageHeight</ var > is
9242+ not an < a > Number</ a > , or is less then 0, return < a > error</ a >
9243+ with < a > error code</ a > < a > invalid argument</ a > .
9244+
9245+ < li > < p > Let < var > margin</ var > be the result of < a > getting a property
9246+ with default</ a > named < code > margin</ code > and with a default of an
9247+ empty < a > Object</ a > from the < var > parameters</ var > argument.
9248+
9249+ < li > < p > Let < var > marginTop</ var > be the result of < a > getting a
9250+ property with default</ a > named < code > top</ code > and with a
9251+ default of < code > 0.39</ code > from < var > margin</ var > .
9252+
9253+ < li > < p > Let < var > marginBottom</ var > be the result of < a > getting a
9254+ property with default</ a > named < code > bottom</ code > and with a
9255+ default of < code > 0.39</ code > from < var > margin</ var > .
9256+
9257+ < li > < p > Let < var > marginLeft</ var > be the result of < a > getting a
9258+ property with default</ a > named < code > left</ code > and with a
9259+ default of < code > 0.39</ code > from < var > margin</ var > .
9260+
9261+ < li > < p > Let < var > marginRight</ var > be the result of < a > getting a
9262+ property with default</ a > named < code > right</ code > and with a
9263+ default of < code > 0.39</ code > from < var > margin</ var > .
9264+
9265+ < li > < p > If any
9266+ of < var > martinTop</ var > , < var > marginBottom</ var > , < var > marginLeft</ var > ,
9267+ or < var > marginRight</ var > is not an < a > Number</ a > , or is less then 0,
9268+ return < a > error</ a > with < a > error code</ a > < a > invalid argument</ a > .
9269+
9270+ < li > < p > Let < var > shrinkToFit</ var > be the result of < a > getting a
9271+ property with default</ a > named < code > shrinkToFit</ code > and with
9272+ default < code > true</ code > from the < var > parameters</ var > argument.
9273+
9274+ < li > < p > If < var > shrinkToFit</ var > is not a < a > Boolean</ a >
9275+ return < a > error</ a > with < a > error code</ a > < a > invalid argument</ a > .
9276+
9277+ < li > < p > Let < var > pageRanges</ var > be the result of < a > getting a
9278+ property with default</ a > named < code > pageRanges</ code > from
9279+ the < var > parameters</ var > argument with default of an
9280+ empty < var > Array</ var > .
9281+
9282+ < li > < p > If < var > pageRanges</ var > is not an < a > Array</ a >
9283+ return < a > error</ a > with < a > error code</ a > < a > invalid argument</ a > .
9284+
9285+ < li > < p > When the user agent is next to < a > run the animation frame
9286+ callbacks</ a > , let < var > pdfData</ var > be the result of < a > trying</ a >
9287+ to take UA-specific steps to generate a paginated representation of
9288+ the < a > current browsing context</ a > as a PDF, with the following
9289+ paper settings:
9290+ < table >
9291+ < tr >
9292+ < th > Property
9293+ < th > Value
9294+ < tr >
9295+ < td > Width in inches
9296+ < td > < var > pageWidth</ var > if < var > orientation</ var > is
9297+ "< code > portrait</ code > " otherwise < var > pageHeight</ var >
9298+ < tr >
9299+ < td > Height in inches
9300+ < td > < var > pageHeight</ var > if < var > orientation</ var > is
9301+ "< code > portrait</ code > " otherwise < var > pageWidth</ var >
9302+ < tr >
9303+ < td > Top margin, in inches
9304+ < td > < var > marginTop
9305+ < tr >
9306+ < td > Bottom margin, in inches
9307+ < td > < var > marginBottom
9308+ < tr >
9309+ < td > Left margin, in inches
9310+ < td > < var > marginLeft
9311+ < tr >
9312+ < td > Right margin, in inches
9313+ < td > < var > marginRight
9314+ </ table >
9315+
9316+ < p > In addition, the following formatting hints should be applied by the UA:
9317+ < dl >
9318+ < dt > If < var > scale</ var > is not equal to < code > 1</ code > </ dt >
9319+ < dd > Zoom the size of the content by a factor < var > scale</ var >
9320+ < dt > If < var > background</ var > is < code > false</ code > </ dt >
9321+ < dd > Suppress output of background images
9322+ < dt > If < var > shrinkToFit</ var > is < code > true</ code > </ dt >
9323+ < dd > Resize the content to match the page width, overriding any
9324+ page width specified in the content
9325+ </ dl >
9326+
9327+ < li > < p > If < var > pageRanges</ var > is not an empty < a > Array</ a > ,
9328+ Let < var > pages</ var > be the result of < a > trying</ a > to < a > parse a
9329+ page range</ a > with arguments < var > pageRanges</ var > and the number of
9330+ pages contained in < var > pdfData</ var > , then remove any pages
9331+ from < var > pdfData</ var > whose one-based index is not contained in
9332+ < var > pages</ var >
9333+
9334+ < li > < p > Let < var > encoding result</ var > be the result of
9335+ calling < a > Base64 Encode</ a > on < var > pdfData</ var > .
9336+
9337+ < li > < p > Let < var > encoded string</ var > be < var > encoding result</ var > ’s data.
9338+
9339+ < li > < p > Return < a > success</ a > with data < var > encoded string</ var >
9340+ </ section > <!-- /Print Page -->
9341+ </ section > <!-- /Print -->
9342+
90769343
90779344< section class =appendix >
90789345< h2 > Privacy</ h2 >
@@ -9262,6 +9529,14 @@ <h2>Index</h2>
92629529 < li > < dfn data-lt ="blocked by content security policy "> < a href =https://w3c.github.io/webappsec-csp/#should-block-navigation-response > Should block navigation response</ a > </ dfn >
92639530 </ ul >
92649531
9532+ < dt > Base16, Base32, and Base64 Data Encodings
9533+ < dd > < p > The following terms are defined
9534+ in The Base16, Base32, and Base64 Data Encodings specification: [[RFC4648]]
9535+ < ul >
9536+ <!-- Base64 Encode --> < li > < dfn > < a href =https://tools.ietf.org/html/rfc4648#section-4 > Base64 Encode</ a > </ dfn >
9537+ </ ul >
9538+
9539+
92659540 < dt > DOM
92669541 < dd > < p > The following terms are defined
92679542 in the Document Object Model specification: [[DOM]]
@@ -9367,6 +9642,7 @@ <h2>Index</h2>
93679642 <!-- PromiseResolve --> < li > < dfn > < a href =https://tc39.github.io/ecma262/#sec-promise-resolve > PromiseResolve</ a > </ dfn >
93689643 <!-- Type --> < li > < dfn data-lt ="ecmascript type " data-lt-noDefault > < a href =https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values > Type</ a > </ dfn >
93699644 <!-- Use strict directive --> < li > < dfn > < a href =https://www.ecma-international.org/ecma-262/5.1/#sec-14.1 > Use strict directive</ a > </ dfn >
9645+ <!-- parseInt --> < li > < dfn > < a href =https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.2 > parseInt</ a > </ dfn >
93709646 <!-- parseFloat --> < li > < dfn > < a href =https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.3 > parseFloat</ a > </ dfn >
93719647 <!-- realm --> < li > < dfn > < a href ="https://tc39.github.io/ecma262/#sec-code-realms "> realm</ a > </ dfn >
93729648 </ ul >
@@ -9644,6 +9920,7 @@ <h2>Index</h2>
96449920 <!-- ASCII lowercase --> < li > < dfn data-lt ="lowercase "> < a href =https://infra.spec.whatwg.org/#ascii-lowercase > ASCII lowercase</ a > </ dfn >
96459921 <!-- Javascript String's length --> < li > < dfn > < a href ="https://infra.spec.whatwg.org/#javascript-string-length "> JavaScript string’s length</ a > </ dfn >
96469922 <!-- queue --> < li > < dfn > < a href =https://infra.spec.whatwg.org/#queues > queue</ a > </ dfn >
9923+ <!-- set --> < li > < dfn > < a href =https://infra.spec.whatwg.org/#sets > Set</ a > </ dfn >
96479924 </ ul >
96489925
96499926 < dt > Interaction
0 commit comments