# Export paginated table

I have a large data set which I need to export as a table to a PDF file. At the moment, I do this by exporting as CSV, applying some styling in Excel (display as table, autofit column width, etc.), and then exporting as PDF. I would like to be able to do it in one step directly from Mathematica.

NotebookPrint combined with the new (v10.3) function TextGrid seems to be able to present the data quite nicely, but the presentation is poor is when the table spans multiple pages. Is there any way to convince Mathematica to repeat column headings on each page, or to determine where page breaks will occur, so that the repeated headings can be inserted?

For example, here's some data:

data = Select[ExampleData[{"Dataset", "Titanic"}] // Normal,
NumericQ[#age] &][[;; 100]];


Extract the keys and put the data into a list of lists:

headings = Keys[First[data]];
dataAsTable = Outer[Lookup[#1, #2, ""] &, data, headings, 1];


I have tried the following two, which (unlike Export) produce a PDF document with sensible page sizes and with the table split between pages:

NotebookPrint[