Feature Rich
Rapid Application Development
Helping you or your customers
Manage their Business

PDF generation

To generate an A4 PDF of any page (large pages will result in a multi-paged PDF), add the variable CONVPAGE=PDF to the URL. For example, https://www.ultimatedb.net/pdf-generation?CONVPAGE=PDF.

This extra variable results in a PDF being created on page load which is available to view or download using the buttons displayed at the top of the page.

PDFs are created and available in the /res/tmp/ folder. This folder is regularly cleaned and any files older than 14 days are deleted. Save a copy of the PDF elsewhere if its needed for longer periods.

Fonts

Note that the server only has a limited number of fonts available when generating PDFs. These include Andale Mono, Arial, Courier New, Georgia, Impact, Times New Roman and Verdana. Use web fonts to ensure that the PDF fonts match the original design.

Page numbers

To add page numbers to the bottom right of each page, for example "Page 1 of 3", add page-numbers to the URL. For example, domain.com?CONVPAGE=PDF&page-numbers.

Landscape

By default, PDFs are portrait. To change the orientation, add landscape to the URL. For example, domain.com?CONVPAGE=PDF&landscape.

Table of contents

To add a table of contents to the beginning of the PDF, add toc to the URL. For example, domain.com?CONVPAGE=PDF&toc. The table of contents is generated based on the H tags in the original document.

Headers and foooters, with page data

To add a header and/or footer to each page of the PDF, create header and footer elements with the class udb-pdf. For example, <header class"udb-pdf">My PDF header</header>. The first header element, and last footer element, with the class udb-pdf, will be removed from the main body and added to each PDF page.

The class attribute, and udb-pdf class must come first in the element tag. The following example will not work,
   <header id="pdf-header" class"udb-pdf">
   <header class"text-muted udb-pdf">
whereas these will work,
   <header class"udb-pdf" id="pdf-header">
   <header class"udb-pdf text-muted">

To include page data in the header or footer, use spans with the following classes,

  • page - Number of the page currently being printed
  • frompage - Number of the first page to be printed
  • topage - Number of the last page to be printed
  • webpage - URL of the page being printed
  • section - Name of the current section
  • subsection - Name of the current subsection
  • date - Current date in system local format
  • isodate - Current date in ISO 8601 extended format
  • time - Current time in system local format
  • title - Title of the of the current page object
  • doctitle - Title of the output document
  • sitepage - Number of the page in the current site being converted
  • sitepages - Number of pages in the current site being converted

For example, 

    <span class="page"></span>

As a full footer example,

    <footer class"udb-pdf">Page <span class="page"></span> of <span class="topage"></span></footer>

will result in a something similar to,

    Page 1 of 3