b. Analytics PDF reports in Reporting are defined using html templates.

You can modify the existing templates or create new ones.


1. Create a PDF template


  1. SSH to your analytics node(s)
  2. Go to /opt/versa/var/van-app/templates/reporting
$ cd /opt/versa/var/van-app/templates/reporting



By default there is currently 2 templates, default.html and versaline.html.

Both templates are visible and usable in reporting, when clicking on "Save and Schedule" button.


1.1. Copy an existing template

You can update the existing templates, or create new ones.


To create a new template, copy default.html and open the new file

$ sudo cp default.html custom.html
$ sudo vi custom.html



Default.html and versaline.html will be replaced upon Analytics restart. If you modify them, make sure to save a copy in a different directory.


You can also disable templates overwriting:

$ sudo vi /opt/versa/var/van-app/properties/application.properties

Add the property:
reporting.templates.overwrite=false




1.2. Modify the template

The html file contains all the instruction to change the CSS styling, colors, headers and footers.

It is recommended to keep CSS styling inside the HTML file.

Make sure to read carefully, in particular how to define images.


To modify the header and footer images, you need to configure 2 locations,


    a. Set your image location in the javascript part:

    <script type="text/javascript">
     var PhantomJSPrinting = {
      header: {
        height: "2.5cm",
        contents: function(pageNum, numPages) {
          return '<div class="logo"><img style="width:20%;padding-top:0px;" alt="logo" src="default_images/logo.png" /></div>'; }
      },
      footer: {
        height: "2.5cm",
        contents: function(pageNum, numPages) {
          return '<img style="width:100%;" src="default_images/footer.png" /><p style="position:absolute; font-size:60%; bottom:10; left:25;">' + pageNum + '/' + numPages + ' <span style="margin-left:45px;">Copyright Versa Networks, Inc. All rights reserved</span></p>';
        }
      }
     };
     </script>

    

    b. Define them a 2nd time line 213 (required for template engine caching)

<div id="pageHeaderFooter">       
    <div class="logo">
        <img alt="logo" src="default_images/logo.png" />
    </div>
     <img alt="logo" src="default_images/footer.png" />
</div>



When you are done, simply save the file. Do not restart Analytics



2. Test your template


The new template will be automatically visible in the list of available templates in the "Save and Schedule" window.


Download an existing report, or create a new one with the corresponding template.

Any changes in the template will be reflected immediately during PDF generation.


When you are satisfied with your changes, copy the HTML template to all the analytics nodes in your cluster. As well, keep a backup of this file into a different location.