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 1414htmlFile = f'{ path } \\ index.html'
1515pdfFile = f'{ path } \\ output.pdf'
1616
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+
1728# Check if the HTML file exists before proceeding
1829if not os .path .exists (htmlFile ):
1930 print (f"HTML file does not exist at: { htmlFile } " )
2031else :
2132 try :
2233 # Convert HTML to PDF
23- pdfkit .from_file (htmlFile , pdfFile , configuration = config )
34+ pdfkit .from_file (htmlFile , pdfFile , configuration = config , options = options )
2435 print (f"Successfully converted HTML to PDF: { pdfFile } " )
2536 except Exception as e :
2637 print (f"An error occurred: { e } " )
You can’t perform that action at this time.
0 commit comments