Complete most part of print to pdf function