Several improvements pdf generation