Skip to content
Snippets Groups Projects
Unverified Commit cfc07b9c authored by incymbalis's avatar incymbalis
Browse files

preferCSSPageSize *does* work after all

parent 6bd3d0b8
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
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