R
R
Roman Vinich2018-11-19 12:40:19
JavaScript
Roman Vinich, 2018-11-19 12:40:19

How to save individual blocks and page elements in the html to pdf converter script?

Hello.
In the script that saves the displayed html page with the content div id="root" to a pdf file on the computer's disk, you need to make an additional. functions.
1. How to add an instruction to the code below that would allow saving only those elements on the html page that have the identifier class="accordion active" to the progect.pdf file, because now the page is saved completely, and I need to save only some of its elements.
Code:
function test() {
var element = document.getElementById('root');
html2pdf().from(element).set({
filename: 'progect.pdf',
html2canvas: { scale: 1 },
jsPDF: {orientation: 'portrait', unit: 'in', format: 'letter', compressPDF :
true} }).save();
}
button onclick="test()"Save the file to disk/button
2. And how is it possible to add to the above code the function of simultaneously opening in the mail program (which is installed by default on the computer, such as outlook) a window with an already nested in the body of the letter progect.pdf file when you click the "Save file to disk" button. I found such a code, but I just don't know how to integrate it with the above code.
Code:
function email(addr, subj)
{
window. open("mailto:" + addr + "?subject=" + subj);
}
button onclick="email('[email protected]','petrovitch na svyazi')">Send email with attachment/button

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question