looks like you’re setting the datasource and triggering the action on on page load.
in that case to do it from another page you need to create a new thing in your database like @Buddha said and use a database trigger to start PDF generation action. Make sure to filter the data by user to get the right data if more than one user can generate PDFs.