Unverified Commit cfc07b9c authored by Sam Korn's avatar Sam Korn

preferCSSPageSize *does* work after all

parent 6bd3d0b8
Pipeline #257 failed with stages
in 3 seconds
......@@ -192,7 +192,7 @@ class Printer extends EventEmitter {
let settings = {
printBackground: true,
displayHeaderFooter: false,
// preferCSSPageSize: options.width ? false : true, // does not currently work with bleeds: needs to be calculated from the document
preferCSSPageSize: options.width ? false : true,
width: options.width,
height: options.height,
orientation: options.orientation,
......@@ -204,20 +204,6 @@ class Printer extends EventEmitter {
}
}
if (!options.width) { // calculate paper size from the first page's dimensions
await page.exposeFunction('setWidthHeight', (width, height) => {
settings.width = `${width}mm`;
settings.height = `${height}mm`;
});
await page.evaluate(() => {
const rect = document.querySelector('.pagedjs_page').getBoundingClientRect();
setWidthHeight(
Math.round(CSS.px(rect.width).to('mm').value),
Math.round(CSS.px(rect.height).to('mm').value)
);
});
}
let pdf = await page.pdf(settings)
.catch((e) => {
console.error(e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment