-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The PI-specific dataframes will first be converted to HTML tables using Jinja templates, and then converted to PDFs using Chromium. Now, users of the script must provide a path to the Chromium/Chrome binary throught the env var `CHROME_BIN_PATH` A html template folder has been added, and the test cases for the PI-specific invoice will now both check whether the dataframe is formatted correctly and if the PDFs are correctly generated. The dockerfile has been to install chromium
- Loading branch information
Showing
5 changed files
with
320 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
</head> | ||
|
||
<style> | ||
table { | ||
font-family: arial, sans-serif; | ||
border-collapse: collapse; | ||
width: 100%; | ||
} | ||
td, th { | ||
border: 1px solid #8d8d8d; | ||
text-align: left; | ||
padding: 8px; | ||
} | ||
th { | ||
text-align: center; | ||
} | ||
tr { | ||
page-break-inside: avoid; | ||
} | ||
tr:nth-child(even) { | ||
background-color: #dddddd; | ||
} | ||
tr:last-child { | ||
background-color: #dddddd; | ||
font-weight: bold; | ||
} | ||
</style> | ||
|
||
<body> | ||
<table> | ||
<tr> | ||
{% for col in data.columns %} | ||
<th>{{col}}</th> | ||
{% endfor %} | ||
</tr> | ||
|
||
{% for i, row in data.iterrows() %} | ||
<tr> | ||
{% for field in row %} | ||
{% if i == data.index[-1] %} | ||
{% if field %} | ||
<th>{{field}}</th> | ||
{% else %} | ||
<td style="border-width: 0;"></td> | ||
{% endif %} | ||
{% else %} | ||
<td>{{field}}</td> | ||
{% endif %} | ||
{% endfor %} | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
</body> | ||
|
||
<script> | ||
// To ensure the HTML invoice table always fit the page when | ||
// printed to PDF, the width of the page is assigned to be | ||
// the width of the table | ||
|
||
var table_width = document.getElementsByTagName('table')[0].clientWidth; | ||
const style = document.createElement('style'); | ||
style.innerHTML = ` | ||
@page { | ||
size: ${table_width}px 1200px; | ||
} | ||
`; | ||
document.head.appendChild(style); | ||
</script> | ||
</html> |
Oops, something went wrong.