Generate pdf from HTML in div using Javascript

0 votes

I have the following HTML code:

<!DOCTYPE html>
<html>
    <body>
        <p>don't print this to pdf</p>
        <div id="pdf">
            <p><font size="3" color="red">print this to pdf</font></p>
        </div>
    </body>
</html>

All I want to do is print to pdf everything found in the div with the id "pdf." 

This must be accomplished with JavaScript. 

The "pdf" document should then be downloaded automatically with the filename "foobar.pdf."

I've been using jspdf for this, however, its only function is "text," which only accepts string data. 

I want to send HTML to jspdf rather than text.

Dec 9, 2022 in Java by Nicholas
• 7,760 points
1,002 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java

0 votes
1 answer

Refresh a page using JavaScript or HTML

This can be solved by using the ...READ MORE

answered Feb 18, 2022 in Java by Aditya
• 7,680 points
514 views
0 votes
0 answers

How to decode jwt token in javascript without using a library?

How can I decode the payload of ...READ MORE

Apr 21, 2022 in Java by Rahul
• 3,380 points
1,558 views
0 votes
0 answers

Generate random number between two numbers in JavaScript

Is it possible to use JavaScript to ...READ MORE

Sep 28, 2022 in Java by Nicholas
• 7,760 points
723 views
0 votes
1 answer

How to decode jwt token in javascript without using a library?

Working unicode text JWT parser function: function parseJwt ...READ MORE

answered Nov 4, 2022 in Java by Damonlang
• 700 points
7,343 views
0 votes
1 answer

Refresh a page using JavaScript or HTML

window.location.reload(); in JavaScript <meta http-equiv="refresh" content="1"> in HTML ...READ MORE

answered Nov 7, 2022 in Java by Damonlang
• 700 points
639 views
0 votes
0 answers

Generate pdf from HTML in div using Javascript

This is my HTML code: <!DOCTYPE html> <html> ...READ MORE

May 9, 2022 in Java-Script by Kichu
• 19,040 points
955 views
0 votes
0 answers

Generate pdf from HTML in div using Javascript

I have the following HTML code: <!DOCTYPE html> <html> ...READ MORE

Aug 10, 2022 in HTML by Deepak
• 980 points
1,339 views
0 votes
1 answer

Presenting docket dtates inside html page by javascript

Use the Docker Engine Api:Docker Engine API ...READ MORE

answered Jun 20, 2018 in Docker by DareDev
• 6,890 points
728 views
0 votes
1 answer

Migrating proxy npm repo in nexus 3

I don't think you can achieve this ...READ MORE

answered Jun 22, 2018 in DevOps Tools by DareDev
• 6,890 points
1,516 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP