We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 2ea75cc + 0a10402 commit c490d98Copy full SHA for c490d98
1 file changed
HTML_to_PDF/main.py
@@ -14,13 +14,24 @@
14
htmlFile = f'{path}\\index.html'
15
pdfFile = f'{path}\\output.pdf'
16
17
+# Adding PDF Options for customized view
18
+options = {
19
+ 'page-size': 'A4',
20
+ 'margin-top': '0.75in',
21
+ 'margin-right': '0.75in',
22
+ 'margin-bottom': '0.75in',
23
+ 'margin-left': '0.75in',
24
+ 'encoding': 'UTF-8',
25
+ 'no-outline': None
26
+}
27
+
28
# Check if the HTML file exists before proceeding
29
if not os.path.exists(htmlFile):
30
print(f"HTML file does not exist at: {htmlFile}")
31
else:
32
try:
33
# Convert HTML to PDF
- pdfkit.from_file(htmlFile, pdfFile, configuration=config)
34
+ pdfkit.from_file(htmlFile, pdfFile, configuration=config,options=options)
35
print(f"Successfully converted HTML to PDF: {pdfFile}")
36
except Exception as e:
37
print(f"An error occurred: {e}")
0 commit comments