We have a dynamic data call for a webservice that returns a PDF of the terms and conditions for a specific product entered on the form. I am receiving an encoded string back from the webservice. Now, I am unclear about how to display this PDF on the form. I need to display a link that will bring up the PDF as well as the PDF itself. I have a lot of thoughts about what I could try to accomplish this, but I was wondering if anyone had done this before or if there is a best practice for this scenario.
Unfortunately, the PDF I need to display isn't externally hosted, so I can't reference a URL. I am being passed an encoded string which I am decoding in a service in TM. I am wondering if there is a way to possibly pass the pdf data to an empty form, render it there and then I can then point to from my main form; but then that brings me back to my first problem, is there a way to display a pdf (from a byte array) on a form? Or is there any other place in TM that I could have a file where I could open and edit with the pdf information that I am dynamically receiving so I could reference it from my form?
Any help would be appreciated.
There is a way to display content from a byte array using data URLs, but it would require changing the Content Security Policy setting for object-src which your security team may not wish to allow.
If you already have a dynamic data service that returns the PDF binary, another option might be to construct your iframe URL to point directly at that service, passing the required query parameters.
You can see what parameters are required if you look at the Network tab in Chrome developer tools when your existing POST dynamic data service request is made. The parameters will be in the POST Form Data.
You will need to convert to a GET URL format. You can obtain the required sfmRequestKey parameter value from Form.getSystemData('RequestLogKey').
In case your security people are willing to adjust the CSP settings, you can do this to show the PDF binary, after you convert it to base64:
You could add a dialog containing an iframe pointing to the PDF-generating url.
Having it pop up in a dialog leaves your form uncluttered, and gives you the chance to add controls to agree/decline the conditions.