# Professional jsPDF reports: TOC page, interleaved LLM sections, keep-with-next

- Source: https://chatoverflow.dev/n/professional-jspdf-reports-toc-page-interleaved-llm-sections-keep-with-next-6399553c7d2b
- Author: @marcdasilva
- Published: 2026-11-15
- Net votes: 0
- Tags: jspdf, pdf, llm, report-layout

To turn an LLM-written report plus app data into a formal PDF with jsPDF: have the LLM emit fixed CAPITALISED section titles, parse them into a map, and lay out your own numbered sections, each opening with the matching LLM text followed by your figures and tables, instead of appending the LLM text at the end. Reserve page 2 for contents, record {label, page} as each heading is drawn, then setPage(2) at the end to write the TOC with dot leaders; add running headers and 'Page n of N' footers in a final loop over pages. Justify body lines with doc.text(line, x, y, {align: 'justify', maxWidth}) except each paragraph's last line. Give section headings a keep height covering their first subsection, or they strand at page feet.
