eKoopmans/html2pdf.js

html2pdf rendered all text as image

depizzol opened this issue · 3 comments

I am using the html2pdf to create a PDF from a html element.
The PDF is being generated, but all texts are being rendered as image.
Can someone please support me?

Code is below:

[reportissue.zip](https://github.com/eKoopmans/html2pdf.js/files/12178314/reportissue.zip)
<title>QualityLab</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<div id="div_Report" class="div_RightFrame" style="width:500px;">

    <input type="button" value="Generate PDF" onclick="Convert_HTML2PDF()">


    <div id="test">

        <!-- REPORT SUMMARY -->
        <div id="div_Report_Summary" style="width:90%; ">

            <h2>1. SUMMARY</h2>

            <table style="width:80%; font-size:10px;">
                <tr>
                    <th>Firstname</th>
                    <th>Lastname</th>
                    <th>Age</th>
                </tr>
                <tr>
                    <td>Jill</td>
                    <td>Smith</td>
                    <td>50</td>
                </tr>
                <tr>
                    <td>Eve</td>
                    <td>Jackson</td>
                    <td>94</td>
                </tr>
                <tr>
                    <td>John</td>
                    <td>Doe</td>
                    <td>80</td>
                </tr>
            </table>

        </div>
    </div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.9.3/html2pdf.bundle.min.js" integrity="sha512-YcsIPGdhPK4P/uRW6/sruonlYj+Q7UHWeKfTAkBW+g83NKM+jMJFJ4iAPfSnVp7BKD4dKMHmVSvICUbE/V1sSw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script> function Convert_HTML2PDF() { var opt = { margin: [10, 10, 10, 10], filename: 'test Report.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, letterRendering: true, logging: true }, jsPDF: { unit: 'mm', format: 'A4', orientation: 'portrait' } }; var element = document.getElementById('test'); //element.addText(10, 10, "Hellow"); // New Promise-based usage: html2pdf().set(opt).from(element).save(); } </script>

because it creates an image from html and converts it to pdf

because it creates an image from html and converts it to pdf

Thanks Vitaliy...
Is there a way to convert the HTML to PDF in text?

yes you can use jspdf or makepdf or mostly react-pdf