File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 14
14
htmlFile = f'{ path } \\ index.html'
15
15
pdfFile = f'{ path } \\ output.pdf'
16
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
+
17
28
# Check if the HTML file exists before proceeding
18
29
if not os .path .exists (htmlFile ):
19
30
print (f"HTML file does not exist at: { htmlFile } " )
20
31
else :
21
32
try :
22
33
# Convert HTML to PDF
23
- pdfkit .from_file (htmlFile , pdfFile , configuration = config )
34
+ pdfkit .from_file (htmlFile , pdfFile , configuration = config , options = options )
24
35
print (f"Successfully converted HTML to PDF: { pdfFile } " )
25
36
except Exception as e :
26
37
print (f"An error occurred: { e } " )
You can’t perform that action at this time.
0 commit comments