fix page break detection
fix page break detection

first write each result to a draft pdf.
if a given result overlaps 2 pages in the draft, in the final pdf,
a page break must first be added before the result itself.

Store actions to write final pdf as closures while writing draft.

doc212/theros,doc212/theros,doc212/theros,doc212/theros,doc212/theros