-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Printing multiple divs? #16
Comments
Hi @andehwong. Sorry, I've been super busy. Since you've asked about it, I'm actually intending to cut a new release soon to support multiple elements. In the mean time, a work around would be to take all of your "ticket divs" and wrap them in one single Something like... // Query for your tickets and spread the `NodeList` into an `Array`
const tickets = [...document.querySelectorAll('.ticket')];
// Create an empty wrapper div
const ticketWrapper = document.createElement("div");
// Deep clone each ticket node and append to the wrapper `<div>`
tickets.forEach(ticket => {
ticketWrapper.appendChild(ticket.cloneNode(true));
});
// Print the wrapper `<div>`
printHtmlElement.printElement(ticketWrapper); Or... // Map over each ticket and return its `outerHTML`, then concatenate the strings
ticketMarkup = tickets.map(ticket => ticket.outerHTML).join('\n');
// Print the markup
printHtmlElement.printHtml(ticketMarkup); I'll leave this issue open to track the feature request |
I managed to use your second method of mapping each ticket to a variable string. It retains the CSS from the original page and it prints each ticket on it's own page.
|
Hello, I'm currently using print-html-element to print off certain "tickets" for my current React application. It works fine if I select single tickets, but my superiors want the function to print off multiple tickets. All these tickets are stored in their own div elements.
I know it's posted that it will be a feature implemented later, but is there a workaround you suggest?
The text was updated successfully, but these errors were encountered: