@segnavia/render 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deck-pdf.js +4 -2
- package/dist/index.js +5 -2
- package/dist/overflow-containment.js +7 -0
- package/package.json +3 -3
package/dist/deck-pdf.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RenderRefusedError } from "./errors.js";
|
|
2
|
+
import { containFixedPageOverflow } from "./overflow-containment.js";
|
|
2
3
|
import { pdfPixelBox } from "./pdf-geometry.js";
|
|
3
4
|
import { composeImposedPdf, drawClippedPage, embedOnePage } from "./pdf-compose.js";
|
|
4
5
|
import { Imposition, fitPage, impose, pagePlacementLayout } from "@segnavia/format";
|
|
@@ -20,6 +21,7 @@ async function regularDeckPdf(deck, opts, services) {
|
|
|
20
21
|
html: slide.content.html
|
|
21
22
|
}] : []);
|
|
22
23
|
const css = `${services.fontFaces(opts)}${opts.css ?? ""}`;
|
|
24
|
+
const slideCss = containFixedPageOverflow(css);
|
|
23
25
|
const notesGeometry = opts.layout === "notes" ? notesLayoutGeometry(deck.size, opts.notesPaper) : void 0;
|
|
24
26
|
const [printable, rendered] = await Promise.all([services.renderPdf({
|
|
25
27
|
viewport: notesGeometry ? {
|
|
@@ -46,7 +48,7 @@ async function regularDeckPdf(deck, opts, services) {
|
|
|
46
48
|
scripts: deck.scripts === "sandboxed",
|
|
47
49
|
html: htmlSlideDocument(deck, html, {
|
|
48
50
|
nonce: newNonce(),
|
|
49
|
-
css
|
|
51
|
+
css: slideCss
|
|
50
52
|
}),
|
|
51
53
|
boundMs: opts.boundMs
|
|
52
54
|
}, {
|
|
@@ -84,7 +86,7 @@ async function regularDeckPdf(deck, opts, services) {
|
|
|
84
86
|
return services.finish(await output.save(), opts);
|
|
85
87
|
}
|
|
86
88
|
async function imposedDeckPdf(deck, imposition, opts, services) {
|
|
87
|
-
const css = `${services.fontFaces(opts)}${opts.css ?? ""}
|
|
89
|
+
const css = containFixedPageOverflow(`${services.fontFaces(opts)}${opts.css ?? ""}`);
|
|
88
90
|
const imposed = impose(imposition, deck.slides.length);
|
|
89
91
|
const rendered = await Promise.all(deck.slides.map(async (slide, index) => {
|
|
90
92
|
const single = {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RenderRefusedError, RendererUnavailableError } from "./errors.js";
|
|
2
|
+
import { containFixedPageOverflow } from "./overflow-containment.js";
|
|
2
3
|
import { renderDeckPdf } from "./deck-pdf.js";
|
|
3
4
|
import { rewriteEffectsPdf } from "./effects/adapter.js";
|
|
4
5
|
import { assertPrintOptions, printCss, printPage, printViewport } from "./page-paper.js";
|
|
@@ -187,7 +188,9 @@ async function openRenderer(options) {
|
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
function pageDocument(page, options, printing = false) {
|
|
190
|
-
const
|
|
191
|
+
const hostCss = `${page.print ? printing ? printCss(page.print) : printProperties(page.print) : ""}${fontFaces(options.fonts)}${options.css ?? ""}`;
|
|
192
|
+
const fixedSize = typeof page.size === "object" && page.size.height !== "auto";
|
|
193
|
+
const css = printing && !page.print && fixedSize ? containFixedPageOverflow(hostCss) : hostCss;
|
|
191
194
|
return frameDocument(page.html, {
|
|
192
195
|
scripts: page.scripts,
|
|
193
196
|
nonce: newNonce(),
|
|
@@ -238,7 +241,7 @@ async function openRenderer(options) {
|
|
|
238
241
|
nonce: newNonce(),
|
|
239
242
|
dir: page.dir,
|
|
240
243
|
lang: page.lang,
|
|
241
|
-
css,
|
|
244
|
+
css: containFixedPageOverflow(css),
|
|
242
245
|
relayKeys: false,
|
|
243
246
|
reportHeight: false
|
|
244
247
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segnavia/render",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@segnavia/format": "0.
|
|
30
|
-
"@segnavia/frame": "0.
|
|
29
|
+
"@segnavia/format": "0.4.0",
|
|
30
|
+
"@segnavia/frame": "0.4.0",
|
|
31
31
|
"playwright-core": "1.55.1",
|
|
32
32
|
"pdf-lib": "^1.17.1"
|
|
33
33
|
}
|