Skip to content

Adding page numbers to footer using fromHTML #274

@rustamli

Description

@rustamli

I am looking for a way to insert page numbers to the footers of PDF pages generated using fromHTML.

Here is a solution I came up with:

pdf.fromHTML($editableContent.get(0), 15, 0, {
    width: 575
}, function() {
    $.each(pdf.internal.pages, function (index, value) {
        if (value) {
            $.each(value, function (innerIndex, innerValue) {
                var continueAfterThis = true;
                if (innerValue.indexOf('$page$') > -1) {
                    value[innerIndex] = innerValue.replace('$page$', index);
                    continueAfterThis = false;
                }
                return continueAfterThis;
            });
        }
    });
});

I just wonder maybe there's a better way of doing this? Can I somehow override addition of footers or headers during fromHTML processing?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions