I have been altering the totals of Sales Orders mid-render by doing simple arithmetic: assign a freemarker variable and set to 0, add the amount on each line to it, but only conditionally.
Do this in separate variables for the subtotal and the tax total (only tax lines get added to the tax total, and only non-tax lines get added to the subtotal). At the end assign the grand total to be the subtotal variable plus the tax total variable. Render the variables' values instead of what's on the Sales Order record object.
This allows us to exclude certain lines from the transaction and make the totals at the end add up to the amount they would with those lines removed.
The lines being removed are those which have their "Closed" column set to Yes.
Is there a better way to do this specific thing (excluding Closed lines from the PDF and its total amounts), like a Preference that I just couldn't find?