Users can download PDFs from Graph View and Map View. SuperWEB2 is supplied with a default template for the downloads, but you can replace this with your own version. You can either use the same PDF template for both graph and map downloads, or use a different template for each.
In order to change the template for PDF downloads, you must create a PDF form containing specific form fields. SuperWEB2 will populate the form fields with the information from the map or graph at download time.
Create a PDF Template
The first step is to create a basic PDF to use as the template.
This should include any static items you want to appear in the downloaded file, such as your company logo, branding, and copyright statements.
You can use whatever tool you like to create the initial document, as long as it can export your document to PDF. For example, you might create the initial document in Microsoft Word:
- When you have finished creating your initial template, export the document to PDF.
- Open your PDF in Adobe Acrobat.
Choose the option to create a form (the exact option will depend on the version of Acrobat you are using):
You may be prompted to confirm how to create the form.
If prompted, choose to create a form From Existing Document:
And choose to base the form on the Current Document:
Then choose the option to Add New Field.
Add the following form fields to your document (the field names must match the ones shown here exactly):
Field Name Will be populated with... Applies to... Map
The graph or map.
Both map and graph downloads. Map Title The table name. Both map and graph downloads. Information Details of what is being counted in the table. Both map and graph downloads. Database Label The name of the database. Both map and graph downloads. Legend The legend/key for the map. Map downloads only. LegendTitle The value of the Field drop-down list from Map View (i.e. it indicates what field is being visualised on the map). Map downloads only.
Position the form fields where you want to items to appear on the page. You will typically want to make the Map field the biggest and most prominent, because this is where the map or graph will be placed in the document.
Use the options in Acrobat to set any field properties that you want to apply to your template, such as the font type, font size and text alignment, as well as border and background colours on the form elements (if any). These properties will be applied at download time when SuperWEB2 writes the map/graph contents to the template.
- On your graph template, right-click the Map field and select Properties, then the Position tab.
- Make a note of the Width and Height of the Map field in inches. You need these values to tell SuperWEB2 how big to generate the graph image that will be placed in the PDF.
Save your graph template as <tomcat_home>\webapps\webapi\WEB-INF\templates\SWDownloadGraph.pdf and save your map template as <tomcat_home>\webapps\webapi\WEB-INF\templates\SWDownloadMap.pdf
- Open <tomcat_home>\webapps\webapi\scripts\sw2-charts\sw2-chart-export-options.js in a text editor.
Edit the values for
chartimgsizeyso that they match the width and height (in inches) of the Map field in your graph template that you obtained from Acrobat. For example:
You may also wish to adjust the
dpivalue. This controls the dots per inch used to render the graph image when creating the PDF. The default is 72dpi, which is standard print resolution.
- Save your changes.
You can now test the template by logging in to SuperWEB2 and creating a table, then downloading a graph and map to PDF.
Other PDF Configuration Settings
In addition to changing the template PDF, there are some other configuration settings you can adjust for PDF downloads.
Depending on your PDF template, you may need to configure SuperWEB2 to embed fonts in PDF downloads.
The Adobe Reader application has a set of default fonts (known as the Adobe Base 14 fonts). These fonts are always available and do not need to be embedded. However, if your document uses other fonts then the PDF will only display correctly if users viewing the PDF have those fonts installed on their computers.
To ensure that your downloaded PDFs always display correctly, regardless of what fonts a user has installed, you can configure SuperWEB2 to embed the fonts in the PDF.
- Open <tomcat_home>\webapps\webapi\WEB-INF\classes\configuration.properties in a text editor.
Locate the following property:
By default the properties are set to no value, which means that SuperWEB2 will not embed any fonts in the PDF.
For each font you want to embed, add the full path to the font file on the machine running SuperWEB2. If you are specifying multiple fonts, separate them with commas. You must use forward slashes in the path. For example:
To obtain the full path to a font installed on your computer, go to Control Panel > Appearance and Personalisation > Fonts, then right-click the font and select Properties:
Save your changes, and then restart Tomcat or the SuperWEB2 service to apply the change.
Graph PDF Settings
The additional graph PDF settings are configured in <tomcat_home>\webapps\webapi\scripts\sw2-charts\sw2-chart-export-options.js.
See sw2-chart-export-options.js for full details.
Map PDF Settings
The additional map PDF settings are configured in <tomcat_home>\webapps\webapi\WEB-INF\classes\configuration.properties. You can change the following settings:
|The Author Document Property in the generated PDF.|
|The Keywords in the Document Properties in the generated PDF.|
|The Application Document Property in the generated PDF.|