Orginal function generatePDF()
Bugfix caculate