Skip to main content
All CollectionsAPI and Developer DocumentationHighly customized reports with Python
Export a custom PDF or HTML file using python and the advanced reporting engine
Export a custom PDF or HTML file using python and the advanced reporting engine

For advanced usage, design your own PDF / HTML output in reports

Zack Schwartz avatar
Written by Zack Schwartz
Updated over 4 months ago

The following article is for advanced usage only is applicable if you want to generate a raw PDF file or HTML of your submission data. Some examples for using this output:

  • Need to hand out a specialized hard copy format for judges

  • Need to print out Fact Cards or Sheets that will display in front of the entries in an in-person judging

  • Display sheets

  • Certificates

  • Publish a Winners Book 

A prerequisite for this article assumes that you know how to create a basic report in OpenWater.

There are two ways to creating a PDF/HTML report.

  • Render from HTML

  • Render from Python Script

To get started with a PDF/HTML export, first navigate to your report and click on Advanced and then check the box for Enable TXT Export. Then click Manage.

Render from HTML

Render from HTML will simply output the PDF/HTML in the format you have written. Click Insert Variable to design your output. See example below.

Tip

You may want each submission to be rendered on its own page in PDF. You can do this by clicking Source button in the editor and surrounding your HTML with the following code.

<div style="page-break-before: always;">

YOUR HTML HERE

</div>

Like so:

Click Save and tab over to General. Refresh your page and you should now see PDF | HTML as an option.

Render from Python Script

This is a more advanced option that requires python code. You would go with this option if a straight rendering from HTML is insufficient in designing the type of output you are looking for.

The PDF/HTML that is rendered as output for the report is actually completely defined by you via a python script. The boilerplate below can be used as the most basic Python report.

#HEADER#
data = []
#END HEADER#

#BODY#
temp = {}
temp["Id"] = {ApplicationCode}
temp["Email"] = {Email}
temp["Category"] = {ApplicationCategoryName}
temp["Title"] = {ApplicationName}
temp["Date"] = {SubmittedAt}
temp["WinnerInfo"] = {ApplicationWinningTypes}
data.append(temp)
#END BODY#

#FOOTER#
print "<html><body>"
all_entries = []
all_entries = sorted(data, key=lambda x: x['Id'])
for item in all_entries:
    print "<span>" + item["Id"] + "</span><br/>"
    print "<span>" + item["Email"] + "</span><br/>"
    print "<span>" + item["Category"] + "</span><br/>"
    print "<span>" + item["Title"] + "</span><br/>"
    print "<span>" + item["Date"] + "</span><br/>"
    print "<span>" + item["WinnerInfo"] + "</span><br/>"
    print "<hr>"
print "</body></html>"
#END FOOTER# 

The #HEADER# section is a good place to define variables that will be stored once. The #BODY# section is rendered once for every submission included in the report. This is where you would want to make use of the variables. And finally #FOOTER# is also rendered once.

The print statements will render that line out to the PDF/HTML output.

Click Save and Run Test which will choose up to 10 submissions to render and output the JSON file. If there are any syntax errors, it will tell you. You can also click Save and Export Script which will generate the resulting Python script for you to analyze for any other debugging purposes.

Run the Report

To run the report in full, return to the General and tab and refresh your page to see PDF/HTML as an option now.

Did this answer your question?