action.skip

How to add web links?

← PDF and Email FAQ

Under certain circumstances, you may want some text in your invoice or statement PDF files to include links – to point to your company's website, for example. So when your users view the PDF file, they can immediately click that link, and they are taken to the website.

This is possible with the two PDF rendering mechanisms that JustOn Billing & Invoice Management supports: Visualforce PDF rendering (v1) and the JustOn PDF service (v2). The options, however, differ.

JustOn's PDF rendering

JustOn Billing & Invoice Management supports two PDF rendering mechanisms, referred to as version 1 and version 2:

  • Salesforce's built-in PDF rendering service generates downloadable, printable PDF files of specifically prepared Visualforce pages – in JustOn, for invoices and statements. Using Visualforce PDF rendering is the standard approach on the Salesforce platform and works for the most use cases. There may, however, apply some limitations. For details, see Visualforce PDF Rendering Considerations and Limitations in the Salesforce Help.
  • JustOn 2.62 has added support for invoice and statement templates using the Liquid template language. To render the files and to produce the corresponding PDF output, JustOn uses a dedicated service based on the Chromium PDF engine. Use this approach if your business requires sophisticated PDF customizations that are difficult or impossible to implement with Visualforce PDF rendering.

As an example, assume you want to add a link to your company's website. To achieve this, you add a complete HTML hyperlink (the <a> tag) to the relevant text, like the page footer:

Visit the <a href="https://www.juston.com">JustOn home page</a>.
  1. Open the template to be edited, and click Edit in the detail view.
  2. In the corresponding field, like Footer, specify the text – including the HTML hyperlink – as required.

    Visit the <a href="https://www.juston.com">JustOn home page</a>.
    

    Optionally, you can use the style attribute or custom CSS rules to modify the link's appearance.

  3. Click Save.

    This produces the intended link in the PDF:

    jo_faq_pdf_href
    Linking to a website from a PDF

Options and Limitations

The solution described above works both with templates v1, which use Visualforce PDF rendering, as well as with templates v2, which are based on Liquid files and the JustOn PDF service. Any current PDF viewer correctly reproduces the links and consequently allows users to follow them.

Be aware, however, of the following specifics.

A number of PDF viewers read URL patterns from the text and present them as clickable links. If you are sure that the recipients of your PDF files use one of those PDF viewers, you can just write the intended link as plain text, that is, without using the HTML hyperlink:

Visit the <a href="https://www.juston.com">JustOn home page</a>. And https://docs.juston.com

This produces plain text upon PDF rendering, but an appropriate PDF viewer presents a link.

jo_faq_pdf_href2
PDF viewer presenting a link from plain text

If you apply document templates version 1, you can make use of placeholders. These are symbols for fields that are replaced with the actual values upon text rendering.

Assume your business requires to handle variable links on invoices, like links to some product group-specific information on your company's website. To hold this variable information, you use the custom Invoice field Information__c. The data type of this field can be Text or URL. Using the custom placeholder [InvoiceInfo], you want to add its content to the PDF file.

Depending on the intended output, there are two ways to do so:

  • You can have the link reproduced as plain text and rely on the PDF reader to present it as a clickable link, as mentioned in Links From Plain Text. In this case, the rendering mode for the placeholder (Render as) does not matter – you can set TEXT or PLAIN.
  • If you need a "real" link as explained in Adding Link, you must make sure to set the placeholder rendering mode to PLAIN.

    With Information__c set to https://www.juston.com and [InvoiceInfo] pointing to Information__c, this line

    <a href="[InvoiceInfo]">Info</a>
    

    produces the following link:

    jo_faq_pdf_href3
    Inserting the link target using a placeholder