Commit 6f6c665f authored by Fred Chasen's avatar Fred Chasen

Merge branch 'cli' into 'master'

Fix height for sheet in print css

See merge request !58
parents 76b786dd 6ef5bac6
# Paged.js Contributions Guide
Whether you're contributing to Pagedjs through development, creating examples, finding bug or just asking questions - thanks in advance for your help!
## I found a bug!
Please file a bug report on our gitlab issues page: https://gitlab.pagedmedia.org/tools/pagedjs/issues
Issues with a HTML file example and correct / incorrect output PDFs are much quicker to debug and very appreciated.
## I fixed something!
We'll review the code on either a github or gitlab pull request and then merge it into the gitlab repository.
## I need help!
Chat with us on mattermost @ https://mattermost.pagedmedia.org/login
You can also open an issue with the `Question` label: https://gitlab.pagedmedia.org/tools/pagedjs/issues?label_name%5B%5D=Question
## I have a great idea for a feature!
Please open an issue with the `Feature Request` label: https://gitlab.pagedmedia.org/tools/pagedjs/issues?label_name%5B%5D=Feature+Request
......@@ -71,14 +71,19 @@ class PuppeteerEnvironment extends NodeEnvironment {
console.log(`TestPage - ${i}: ${msg.args()[i]}`);
});
// await page.exposeFunction('PuppeteerLogger', (msg, counter) => {
// console.log(msg, counter);
// });
await page.exposeFunction('onPagesRendered', (msg, width, height, orientation) => {
await page.exposeFunction('onRendered', (msg, width, height, orientation) => {
renderedResolve(msg, width, height, orientation);
});
await page.evaluateOnNewDocument(() => {
document.addEventListener("DOMContentLoaded", () => {
window.PagedPolyfill.on("rendered", (flow) => {
let msg = "Rendering " + flow.total + " pages took " + flow.performance + " milliseconds.";
window.onRendered(msg, flow.width, flow.height, flow.orientation);
});
});
});
await page.goto(ORIGIN + '/specs/' + path, { waitUntil: 'networkidle2' });
return page;
......
......@@ -193,6 +193,7 @@ class AtPage extends Handler {
this.addRootPage(ast, this.pages["*"].size, bleed);
this.emit("size", { width, height, orientation, format, bleed });
this.emit("atpages", this.pages);
}
}
......
......@@ -480,5 +480,12 @@ img {
page-break-after: always;
break-after: page;
}
.pagedjs_sheet {
margin: 0;
padding: 0;
max-height: 100%;
min-height: 100%;
height: 100% !important;
}
}
`;
......@@ -32,13 +32,8 @@ class Previewer {
orientation: undefined
};
let counter = 0;
this.chunker.on("page", (page) => {
counter += 1;
this.emit("page", page);
if (typeof window.PuppeteerLogger !== "undefined") {
window.PuppeteerLogger("page", counter);
}
});
this.chunker.on("rendering", () => {
......@@ -54,6 +49,11 @@ class Previewer {
this.emit("size", size);
});
handlers.on("atpages", (pages) => {
this.atpages = pages;
this.emit("atpages", pages);
});
return handlers;
}
......@@ -136,15 +136,11 @@ class Previewer {
let flow = await this.chunker.flow(content, renderTo);
let endTime = performance.now();
let msg = "Rendering " + flow.total + " pages took " + (endTime - startTime) + " milliseconds.";
flow.performance = (endTime - startTime);
flow.size = this.size;
this.emit("rendered", msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation, this.size.format);
if (typeof window.onPagesRendered !== "undefined") {
window.onPagesRendered(msg, this.size.width && this.size.width.value + this.size.width.unit, this.size.height && this.size.height.value + this.size.height.unit, this.size.orientation, this.size.format);
}
this.emit("rendered", flow);
return flow;
}
......
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