Page numbers and icon

Is it possible to generate a PDF document from HTML with page numbers? How would that be done?

Also, how can I create a PDF from HTML containing icons from say googles material-design icons? Is it possible to insert any kind of icons?

Thanks

Hi @anderstechlogic,

HTML to PDF uses wkhtmltopdf tool. So, you may use a cutom javascript to show the page number or/and total pages you in your footer or header in the Convert HTML to PDF action:

image

 <!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <script>
        function substitutePdfVariables() {

            function getParameterByName(name) {
                var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
                return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
            }

            function substitute(name) {
                var value = getParameterByName(name);
                var elements = document.getElementsByClassName(name);

                for (var i = 0; elements && i < elements.length; i++) {
                    elements[i].textContent = value;
                }
            }

            ['frompage', 'topage', 'page', 'webpage', 'section', 'subsection', 'subsubsection']
                .forEach(function(param) {
                    substitute(param);
                });
        }
    </script>
</head>
<body onload="substitutePdfVariables()">
    <p>Page <span class="page"></span> of <span class="topage"></span></p>
</body>
</html>

image

You may check this forum thread for more information.

If you can insert the icons into the HTML template then our action will convert them and insert into the PDF document.

Best regards,
Petr Bushuev
Plumsail team

1 Like

Thanks for the help. Your answer provided my with all the information needed

1 Like