Skip to content

Commit

Permalink
feat: Support printing mixed page sizes
Browse files Browse the repository at this point in the history
- resolves #751

This change enables mixed page sizes in output PDF together with the following change in vivliostyle-cli:

- vivliostyle/vivliostyle-cli#278

When multiple page sizes are specified, as in the example in Issue 751,
the largest page size both vertically and horizontally are used in PDF output
from Vivliostyle.js.
Then the PDF is post-processed in the Vivliostyle CLI to set the multiple page sizes as specified.
  • Loading branch information
MurakamiShinyu committed May 2, 2022
1 parent 9b33cc5 commit d618b5e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/core/src/vivliostyle/adaptive-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,17 @@ export class AdaptiveViewer {
pageIndex: number,
) {
if (!this.pageSheetSizeAlreadySet && this.pageRuleStyleElement) {
let styleText = "";
Object.keys(pageSheetSize).forEach((selector) => {
styleText += `@page ${selector}{margin:0;size:`;
const size = pageSheetSize[selector];
styleText += `${size.width}px ${size.height}px;}`;
let width = 0;
let height = 0;
Object.values(pageSheetSize).forEach((size) => {
if (size.width > width) {
width = size.width;
}
if (size.height > height) {
height = size.height;
}
});
const styleText = `@page {margin:0;size:${width}px ${height}px;}`;
this.pageRuleStyleElement.textContent = styleText;
this.pageSheetSizeAlreadySet = true;
}
Expand Down

0 comments on commit d618b5e

Please sign in to comment.