R
R
Roman Vinich2018-11-19 10:11:11
JavaScript
Roman Vinich, 2018-11-19 10:11:11

Is it possible to save individual page elements with a script that converts html to pdf file?

Hello.
There is a script that saves an html page with the content div id="root" to a pdf file on the computer's disk.
Please help me understand a couple of questions:
1. How to add an instruction to the code below, which would allow saving to the progect.pdf file only those elements on the html page that have the identifier class="accordion active", 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',
}).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 a mail program (which is installed by default on a computer, such as outlook) a window with an already nested in the body emails with the 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 an email with an attachment/button
Please help, whoever can in solving this issue.
Thanks in advance to everyone who will respond.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Taratin, 2018-11-19
@Taraflex

There is a script

But you won't show it to us, will you?
Before calling your script, remove all elements from the page except class="accordion active"

R
Roman Vinich, 2018-11-19
@Ron2

Sorry, but when posting my question, the script code was not displayed, now I hope you understand that (as you wrote) "remove all elements from the page except class="accordion active" will not solve this problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question