Summary of problem: I cannot get the table of contents generator to work in pdfkit for Python.
What I have tried: Passing argument toc.
My current code:
toc = {'xsl-style-sheet': 'toc.xsl'}
pdfkit.from_file(
book_html_filename, book_pdf_filename,
configuration=config,
toc=toc,
options=options,cover=cover_html_filename,cover_first=True)
I am not familiar with .xsl at all, and therefore I don't know for example what should go into that file.
My current .xsl file:
I mean it is empty. I get the following error message:
Exception has occurred: OSError
wkhtmltopdf reported an error:
Loading pages (1/6)
[> ] 0%
[===> ] 5%
[======> ] 10%
[==================> ] 30%
[=================================> ] 55%
[=============================================> ] 75%
[============================================================] 100%
Counting pages (2/6)
[===================> ] Object 1 of 3
[============================================================] Object 3 of 3
Error XTSE0010 in file:///C:/Program%20Files/wkhtmltopdf/bin/wkhtmltopdf.exe, at line 1, column 0: Parse error: Premature end of document.
Loading TOC (3/6)
[======> ] 10%
[============================================================] 100%
Error XTSE0010 in file:///C:/Program%20Files/wkhtmltopdf/bin/wkhtmltopdf.exe, at line 1, column 0: Parse error: Premature end of document.
[======> ] 10%
[============================================================] 100%
Resolving links (4/6)
[===================> ] Object 1 of 3
[=======================================> ] Object 2 of 3
[============================================================] Object 3 of 3
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[========> ] Page 1 of 7
[================> ] Page 2 of 7
[=========================> ] Page 3 of 7
[==================================> ] Page 4 of 7
[==========================================> ] Page 5 of 7
[===================================================> ] Page 6 of 7
[============================================================] Page 7 of 7
Done
File "C:\Users\User\Documents\GitHub\SeferMaker\py\create_pdf_with_pdfkit.py", line 40, in <module>
pdfkit.from_file(