How can I generate a custom PDF using CiviCRM?
You might want to make the invoiceName end with a .pdf

so:

$invoiceName = "{$participantName}-{$eventName}.pdf";

The third parameter return the pdf if set to true, else initiates a file download via the browser

the 4th parameter is optional and is used to send additional (or override the default) parameters to the pdf code