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 printedfrompage- Number of the first page to be printedtopage- Number of the last page to be printedwebpage- URL of the page being printedsection- Name of the current sectionsubsection- Name of the current subsectiondate- Current date in system local formatisodate- Current date in ISO 8601 extended formattime- Current time in system local formattitle- Title of the of the current page objectdoctitle- Title of the output documentsitepage- Number of the page in the current site being convertedsitepages- 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
UDB PDF Generation
Generate a PDF
To generate an A4 PDF of any UDB page, add CONVPAGE=PDF to the URL. Large pages produce multi-page PDFs.
Example:
https://www.ultimatedb.net/pdf-generation?CONVPAGE=PDF
When CONVPAGE=PDF is present, a PDF is created when the page loads. Buttons displayed at the top of the page allow the PDF to be viewed or downloaded.
PDF storage and retention
Generated PDFs are stored in the /res/tmp/ folder.
The /res/tmp/ folder is regularly cleaned. Files older than 14 days are deleted. Save a copy of a PDF elsewhere if it is needed for longer than 14 days.
PDF fonts
The PDF-generation server has only a limited set of fonts available:
- Andale Mono
- Arial
- Courier New
- Georgia
- Impact
- Times New Roman
- Verdana
Use web fonts to ensure that the fonts in the PDF match the original design.
PDF page numbers
To add page numbers to the bottom right of each PDF page, add page-numbers to the URL.
Example:
domain.com?CONVPAGE=PDF&page-numbers
The page-number format can be similar to Page 1 of 3.
Landscape PDF orientation
PDFs use portrait orientation by default. To use landscape orientation, add landscape to the URL.
Example:
domain.com?CONVPAGE=PDF&landscape
PDF table of contents
To add a table of contents to the beginning of the PDF, add toc to the URL.
The table of contents is generated from the heading tags in the original document.
Example:
domain.com?CONVPAGE=PDF&toc
Page data in PDF headers and footers
To include PDF page data in a header or footer, add a span element using one of the following classes:
| Class | Value inserted into the PDF |
|---|---|
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 the system local format. |
isodate |
Current date in ISO 8601 extended format. |
time |
Current time in the system local format. |
title |
Title 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. |
PDF page-data examples
Display the current page number
<span class="page"></span>
Display “Page 1 of 3” in a footer
<footer class="udb-pdf">Page <span class="page"></span> of <span class="topage"></span></footer>
This produces output similar to:
Page 1 of 3