You will probably want to create the PDF using the HTTP API?
https://pdfcrowd.com/doc/api/html-to-pdf/http/
I imagine here is where you might start (though I could be mistaken!)
If you use create object
it can create the json headers you need for the API to create the PDF. That link has most of what you need to complete it.
(ignore the button click component that’s just for the example)