0

i want to get my div content with all its css styling as pdf file but when i click on button to get pdf it show only its html content not its css styling tere are my code of js and html i do this work with jsPDF library

    function Convert_Html() {
        var doc = new jsPDF();
        var elementHTML = $('#con').;
        var specialElementHandlers = {
            '#elementH': function (element, renderer) {
                return true;
            }
        };
        doc.fromHTML(elementHTML, 15, 15, {
            'width': 170,
            'elementHandlers': specialElementHandlers
        });
        doc.save('id.pdf');
    }
</script>

my html code

<div id="con">
    <div class="id-card-wrapper">
        <div class="id-card">
            <div class="profile-row">
                @*<div class="dp">
                    <div class="dp-arc-outer"></div>
                    <div class="dp-arc-inner"></div>
                    <img src="https://via.placeholder.com/420x420">
                </div>*@
                <div class="desc">
                    <h1>Tony Stark</h1>
                    <p>Strength: Ironman Suit</p>
                    <p>Weakness: None</p>
                    <p>Known as: Iron Man</p>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="elementH"></div>
<button onclick="Convert_Html();">Get</button>

here i am getting problem it give only it html not all css

  • Google `stackoverflow.com: div to pdf + css` gives a ton of results. There's no need to ask before searching.. did you search? – vsync Feb 23 '20 at 22:34
  • yes i serach but its giving an result through paid API can i get the free API – Hassan Asif Feb 23 '20 at 22:40
  • Well, I see free service mentioned in the discussion which I've marked as duplicate, so try those. Also, if you are looking specifically for **free** ones than you should have mentioned in in your question not to waste people's time to have them focus only on *free* solutions. – vsync Feb 24 '20 at 09:14

0 Answers0