[api-minor] Add a new getXfaPageViewport helper function to support printing

This patch provides an overall simpler *and* more consistent way of handling the `viewport` parameter during printing of XFA forms, since it's now again guaranteed to always be an instance of `PageViewport`.
Furthermore, for anyone attempting to e.g. implement custom printing of XFA forms this probably cannot hurt either.
This commit is contained in:
Jonas Jenwald 2021-06-18 12:31:58 +02:00
parent 45c1390c42
commit 87be43c193
6 changed files with 28 additions and 16 deletions

View file

@ -606,6 +606,20 @@ class PDFDateString {
}
}
/**
* NOTE: This is (mostly) intended to support printing of XFA forms.
*/
function getXfaPageViewport(xfaPage, { scale = 1, rotation = 0 }) {
const { width, height } = xfaPage.attributes.style;
const viewBox = [0, 0, parseInt(width), parseInt(height)];
return new PageViewport({
viewBox,
scale,
rotation,
});
}
export {
addLinkAttributes,
DEFAULT_LINK_REL,
@ -616,6 +630,7 @@ export {
DOMSVGFactory,
getFilenameFromUrl,
getPdfFilenameFromUrl,
getXfaPageViewport,
isDataScheme,
isPdfFile,
isValidFetchUrl,