You can add page numbers to the header or footer of all PDF exports in KnowledgeOwl, though the exact setup varies a bit based on the type of PDF.
Individual article PDFs
To add page numbers to your individual article PDFs:
- Go to Customize > PDF.
- Add PDF header HTML or PDF footer HTML that includes the
[pdf("page-number")]
merge code. For example, you can add a centered div like this to create a "Page [number]" treatment:<div style="text-align: center;">Page [pdf("page-number")]</div>
- Be sure to Save your changes.
Standard & Custom PDF exports
For both the Standard and Custom PDF exports, you don't need to add full HTML. You can just add the page number merge code directly to the relevant field:
- Go to Tools > Exports.
- Select Standard PDF to edit the full knowledge base standard PDF, or Custom PDFs and then the gear icon next to the custom PDF you'd like to add page numbers to.
- Copy the merge code below and add it to the Content footer left, Content footer center, or Content footer right.
[pdf("page-number")]
- Be sure to Save and generate your PDF export.
There are two ways to customize the look and feel of individual article PDFs.
For general structure/layout of individual articles, go to Customize > PDF and adjust the settings there--you can add a watermark, password, header HTML, and footer HTML.
But if you want to show or hide content in all PDFs, custom CSS is your friend. All PDF content is prefixed with the hg-pdf
CSS class, so you can target this class in your selectors to show or hide content in PDFs.
One of the most common requests we get is to display a logo or other image in article PDFs that isn't displayed in the live knowledge base. Here's how we achieve that:
- Go to Customize > Style (Custom HTML & CSS).
- In the Customize HTML, CSS, and JS section, select Custom HTML.
- In the Select HTML section to edit dropdown, select Article.
- Near the top of your article, wherever you'd like the logo to appear, add some HTML for your logo. We recommend using a div with a
pdf-logo
class and putting the image inside that div, like this:<div class="pdf-logo" align="center"> <img src="https://dyzz9obi78pm5.cloudfront.net/app/image/id/1111/n/pdflogo.png" /> </div>
- If you use the above code as a sample, replace the img src URL in row 2 with a URL of a valid image file in your Files library.
- Go to Custom CSS.
- Copy the CSS below and paste it into your Custom CSS. The first CSS piece hides the PDF logo in the live knowledge base; the second displays it in PDFs.
/* Hide PDF logo in live knowledge base */ .pdf-logo { display:none; } /* Display PDF logo in PDFs only */ .hg-pdf .pdf-logo { display:block; }
- Be sure to Save your changes.
Changes won't show immediately
PDFs won't immediately update to show these changes. You'll only see the changes in:
- Articles created after you made the changes.
- Articles edited and saved after you made the changes (we usually use a specific article to test with and add/remove a line of text and re-save to test our formatting changes).
For individual article PDFs as well as the standard and custom PDF export options, sometimes a page break comes between two chunks of content you'd like to stay together (such as a numbered step and the screenshot that goes with that numbered step).
If you'd like to be able to enforce a page break before or after certain portions of an article, you can create a snippet that will force a PDF page break.
To do so:
- Go to Library > Snippets.
- Select the + Create New Snippet button.
- This will open a new page where you can define your snippet.
- Be sure to give it a Snippet Name. Here, we use "PDF Page Break After."
- The merge code will be automatically generated based on the snippet name.
- Add a Snippet Description to explain what this snippet does. For example: "Add this snippet anywhere in individual articles where you'd like to force a page break in the PDF exports."
- In the Snippet Editor, be sure Code Editor is selected from the dropdown.
- Copy the code below and paste it into the Code Editor. This code creates an empty paragraph with CSS to force a page break after it:
<p style="page-break-after:always;"></p>
- Click the Create button. Your completed snippet should look something like this:
- Now that your snippet exists, use the Insert Snippet option in the editor to add the snippet into the place in any article where you'd like the page break to occur.
If you have table rows that span multiple lines, by default, the PDF generator won't make any effort to keep those multi-line rows on the same page if they fall on a page break. This is most evident when you have table row headers:
You can add some Custom CSS to prevent this mid-row page break and force page breaks to occur between table rows:
- Go to Settings > Style.
- Copy the code below and paste it anywhere into the Custom CSS section below the preview pane.
Your code should look like this:/* Force PDF page breaks between rows, not mid-row */ .hg-pdf table tr { page-break-inside: avoid; }
- Save.
Once you re-save the article, your PDF should now break properly between the rows:
As with all PDF style settings, by default this style change will only be applied to existing articles once they are resaved. Contact us to have all of your existing article PDFs regenerated with the new style.
To choose where to insert page breaks in an article, check out our Snippet to Force Page Breaks in PDFs.
The PDF generator creates clickable hyperlinks for most hyperlinks. (It doesn't handle anchor hyperlinks well.)
But if you're using PDFs as printed resources, you may want to also display the actual URL of the hyperlink. You can display something like this:
To create these parentheses with the full URL text automatically, add some CSS to your knowledge base and then regenerate PDFs:
- Go to Customize > Style (Custom HTML & CSS). The Style Settings page opens.
- In the Customize HTML, CSS, and JS section, select Custom CSS.
- Copy the code below and paste it into the bottom of your Custom CSS.
.ko-pdf-clickable-link {display: initial;}
- Save your changes.
The color and size of the hyperlinks will vary based on your Style Settings.
This Custom CSS will not generate clickable hyperlinks for same-page anchors.