din-6771 orientation set in page

This commit is contained in:
Laurier Loiselle 2023-04-11 17:31:10 -04:00
parent 19a6c04496
commit e1cf97c8fd
No known key found for this signature in database
GPG Key ID: 345920CC72089A3F
2 changed files with 11 additions and 16 deletions

View File

@ -92,7 +92,7 @@
<style type="text/css" media="print">
@page {
size: auto;
size: {{ sheetsize }} {{ orientation }};
margin: 0;
}

View File

@ -63,14 +63,9 @@ def generate_pdf_output(
filename_list: List[Path],
options: Dict=None,
):
#options = options if options is not None else {}
# TODO: pass intelligent options
options = {
'options': {
'page-size': 'A3',
'orientation': 'landscape',
}
}
'''Generate a pdf output, options are ignored for now, expect the formatting
to be done within the html files
'''
if isinstance(filename_list, Path):
filename_list = [filename_list]
output_path = filename_list[0].with_suffix('.pdf')
@ -84,9 +79,8 @@ def generate_pdf_output(
print(f'Generating pdf output: {output_path}')
html = HTML(filename=filepath_list[0])
#html.write_pdf(output_path)
css = CSS(string='@page { size: A3 landscape; margin: 1cm; }')
html.write_pdf(output_path, stylesheets=[css])
html.write_pdf(output_path)
def generate_html_output(
filename: Path,
@ -148,7 +142,8 @@ def generate_html_output(
added_metadata = {
"revisions": [],
"authors": [],
"sheetsize": "sheetsize_default",
"sheetsize": "A4",
"orientation": "portrait",
}
if metadata:
for item, contents in metadata.items():
@ -163,9 +158,9 @@ def generate_html_output(
elif item == "pn":
added_metadata[item] = f'{contents}-{metadata.get("sheet_name")}'
elif item == "template":
added_metadata["sheetsize"] = contents.get(
"sheetsize", "sheetsize_default"
)
added_metadata["sheetsize"] = contents.get("sheetsize", "A4")
if added_metadata["sheetsize"] in ["A2", "A3"]:
added_metadata["orientation"] = "landscape"
else:
added_metadata[item] = contents