Increase the max execution time (although it is already too long IMHO), or improve your code for the generation of the PDF document. Another approach might be queuing a job to generate the PDF in the background and then notify the user whenever it has been completed
@ahkeravi I would suggest that (i) you @ the OP rather than me, and (ii) that 6 minutes is a very long execution time, and not reasonable in most circumstances.
@ahkeravi As @tykus is saying, simply bumping the max execution time would get rid of the error... but that is like putting a bandaid over a hole in a sinking boat. It's a bad idea.
@theldess There is something in your code that is causing this to run slow. We don't really have enough information here to say anything else about it. Narrow down the issue if you can and say more about the problem.