mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
XFA - Add support to print XFA forms
This commit is contained in:
parent
8c53bf8647
commit
a434011517
7 changed files with 130 additions and 35 deletions
|
@ -13,6 +13,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DefaultXfaLayerFactory } from "./xfa_layer_builder.js";
|
||||
|
||||
const CSS_UNITS = 96.0 / 72.0;
|
||||
const DEFAULT_SCALE_VALUE = "auto";
|
||||
const DEFAULT_SCALE = 1.0;
|
||||
|
@ -994,6 +996,29 @@ function apiPageModeToSidebarView(mode) {
|
|||
return SidebarView.NONE; // Default value.
|
||||
}
|
||||
|
||||
function getXfaHtmlForPrinting(printContainer, pdfDocument) {
|
||||
const xfaHtml = pdfDocument.allXfaHtml;
|
||||
const factory = new DefaultXfaLayerFactory();
|
||||
const scale = Math.round(CSS_UNITS * 100) / 100;
|
||||
for (const xfaPage of xfaHtml.children) {
|
||||
const page = document.createElement("div");
|
||||
page.setAttribute("class", "xfaPrintedPage");
|
||||
printContainer.appendChild(page);
|
||||
|
||||
const { width, height } = xfaPage.attributes.style;
|
||||
const viewBox = [0, 0, parseInt(width), parseInt(height)];
|
||||
const viewport = { viewBox, scale, rotation: 0 };
|
||||
|
||||
const builder = factory.createXfaLayerBuilder(
|
||||
page,
|
||||
null,
|
||||
pdfDocument.annotationStorage,
|
||||
xfaPage
|
||||
);
|
||||
builder.render(viewport, "print");
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
animationStarted,
|
||||
apiPageLayoutToSpreadMode,
|
||||
|
@ -1010,6 +1035,7 @@ export {
|
|||
getOutputScale,
|
||||
getPageSizeInches,
|
||||
getVisibleElements,
|
||||
getXfaHtmlForPrinting,
|
||||
isPortraitOrientation,
|
||||
isValidRotation,
|
||||
isValidScrollMode,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue