admin管理员组

文章数量:1405636

So,

I've successfully modified everything else but can't figure how to change just the footers font size, it is now way too big pared to table font itself.

    let pdf = new jsPDF({orientation: 'l'});
    let res = pdf.autoTableHtmlToJson(document.getElementById('capture'));
    const totalPagesExp = '{total_pages_count_string}';
    let height = pdf.internal.pageSize.getHeight();

    const footer = function(res) {
        let str = 'Sivu ' + res.pageCount;

        if (typeof pdf.putTotalPages === 'function') {
            str = str + ' / ' + totalPagesExp;
            str = str + ' -- ' + moment().format('L').toString();
        }

        //PROBLEM GOES HERE
        pdf.text(str, 5, height - 5, {
            fontSize: 5
        });
    };

    pdf.autoTable(
        res.columns,
        res.data,
        {margin: {top: 25, bottom: 15},
        styles: {overflow: 'linebreak',
                fontSize: 6},
        showHeader: 'everyPage',
        afterPageContent: footer,
        theme: 'plain'});

    if (typeof pdf.putTotalPages === 'function') {
        pdf.putTotalPages(totalPagesExp);
    }

    pdf.save( 'file.pdf');

Footer itself is iterating nicely, page numbers show up as they are suppose to, but even if i pass options object into psd.text() as stated in documentation, it still wont change the font size.

Documentation for text

So,

I've successfully modified everything else but can't figure how to change just the footers font size, it is now way too big pared to table font itself.

    let pdf = new jsPDF({orientation: 'l'});
    let res = pdf.autoTableHtmlToJson(document.getElementById('capture'));
    const totalPagesExp = '{total_pages_count_string}';
    let height = pdf.internal.pageSize.getHeight();

    const footer = function(res) {
        let str = 'Sivu ' + res.pageCount;

        if (typeof pdf.putTotalPages === 'function') {
            str = str + ' / ' + totalPagesExp;
            str = str + ' -- ' + moment().format('L').toString();
        }

        //PROBLEM GOES HERE
        pdf.text(str, 5, height - 5, {
            fontSize: 5
        });
    };

    pdf.autoTable(
        res.columns,
        res.data,
        {margin: {top: 25, bottom: 15},
        styles: {overflow: 'linebreak',
                fontSize: 6},
        showHeader: 'everyPage',
        afterPageContent: footer,
        theme: 'plain'});

    if (typeof pdf.putTotalPages === 'function') {
        pdf.putTotalPages(totalPagesExp);
    }

    pdf.save( 'file.pdf');

Footer itself is iterating nicely, page numbers show up as they are suppose to, but even if i pass options object into psd.text() as stated in documentation, it still wont change the font size.

Documentation for text

Share Improve this question asked Dec 12, 2018 at 12:10 ClomezClomez 1,5225 gold badges27 silver badges44 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4
pdf.setFontSize(5);

and remember to put it before putting the text into footer,

        pdf.setFontSize(5);
        pdf.text(str, 5, height - 5, {
            styles: { fontSize: 5 },
        });

本文标签: javascriptFont size for footerin jsPDF autoTableStack Overflow