jsPDF can't fit html table on a4

Viewed 73

I have table in html. I want to use jsPDF library to make a pdf. But my table oversized a4 page size. How to fit table in a4 page.

My react code:

export default function OfferPDF({offer, paramsId}) {
    
    const generatePDF = () => {
        const pdfSize = 'a4';
        const doc = new jsPDF('p', 'pt', pdfSize);
        doc.setFont('Ubuntu', 'normal');
        doc.html(document.getElementById('pdf-content'), {
            callback: function (pdf) {
                pdf.save(`${offer.offers_year}/${offer.offers_no}.pdf`);
            }
        });
    }
    

    return (
        <div id="pdf-content">

            <table className="table table-bordered">
                <tbody>
                <tr>
                    <td>Müşteri</td>
                    <td>{offer.trade_name}</td>
                    <td>Bilgi</td>
                    <td>{offer.information}</td>
                </tr>
                ...
                </tbody>
            </table>
            <button onClick={generatePDF}>Pdf</button>
        </div>
    );
}

My html view html view

My pdf view my pdf view

0 Answers
Related