In the stage of set to shipped, a web site owner send trace order info to client, to confirm that the ordered product has be sent to buyer, in the email, there is an attaced pdf invoice.
Email sending, I use libmail, which is able to attach a file.
PDF creating, I use htmltopdf.php class.