How to total the rate column in Quote or Sales order or Sales Invoice

How to total the rate column in Quote or Sales order or Sales Invoice?

If required on the form , via Customisation / custom script .
if required in the print format via custom print format.