Creating tear sheet or printable product page by adding custom code.

This is the code i am implementing, Is there any advice you can give me to make it work or improve it?