1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #13613 from Snuffleupagus/xfa-printing-tweaks

[api-minor] Slightly tweak/improve various code related to XFA-printing
This commit is contained in:
Tim van der Meij 2021-06-23 21:56:29 +02:00 committed by GitHub
commit f74562b19c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 109 additions and 82 deletions

View file

@ -743,8 +743,10 @@ class PDFDocumentProxy {
}
/**
* NOTE: This is (mostly) intended to support printing of XFA forms.
*
* @type {Object | null} An object representing a HTML tree structure
* to render the XFA, or `null` when no XFA form exists.
* to render the XFA, or `null` when no XFA form exists.
*/
get allXfaHtml() {
return this._transport._htmlForXfa;

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,

View file

@ -13,8 +13,6 @@
* limitations under the License.
*/
import { PageViewport } from "./display_utils.js";
class XfaLayer {
static setupStorage(html, fieldId, element, storage, intent) {
const storedData = storage.getValue(fieldId, { value: null });
@ -134,13 +132,8 @@ class XfaLayer {
const rootDiv = parameters.div;
rootDiv.appendChild(rootHtml);
let { viewport } = parameters;
if (!(viewport instanceof PageViewport)) {
viewport = new PageViewport(viewport);
}
const coeffs = viewport.transform.join(",");
rootDiv.style.transform = `matrix(${coeffs})`;
const transform = `matrix(${parameters.viewport.transform.join(",")})`;
rootDiv.style.transform = transform;
// Set defaults.
rootDiv.setAttribute("class", "xfaLayer xfaFont");

View file

@ -18,6 +18,7 @@ import {
addLinkAttributes,
getFilenameFromUrl,
getPdfFilenameFromUrl,
getXfaPageViewport,
isPdfFile,
isValidFetchUrl,
LinkTarget,
@ -108,6 +109,7 @@ export {
loadScript,
PDFDateString,
RenderingCancelledException,
getXfaPageViewport,
// From "./display/api.js":
build,
getDocument,