Creating PDFs is notoriously difficult in Power Apps unless you are okay with a simple Word template. We started to use this function together with Power Automate to generate PDFs when the business logic of PDF content increased as well as requirement for quick PDF creation. It's been a few months now that PDF function worked like a charm for us.
We have a rather non-trivial A3 custom page which displays few pictures from SharePoint depending on the currently opened record in model-driven app which upon clicking a button triggers a PDF function and the result of the PDF function is sent to Power Automate to create a file on SharePoint as per MS official docs for working with PDF function.
However, in the last week or so, the previously amazing time of about 10s became 2+ minutes! I could not quite believe this at first when it was reported and went on to check network and computer of the user, but to my surprise the result is same for everyone.
The problem:
Simply put - Pictures.
Specifically the ones from SharePoint. We already overcame the issue that URL are not sufficient for PDF function, so we were using Power Automate to get the file contents. This was the first thing that we changed to use only thumbnails instead of base64 of the entire picture (thought that could have been unnecessary to transfer that much data). Did not help tho.
Weird behavior difference between Power Apps Studio and MD App:
In Power Apps Studio the PDF function takes a bit longer than before (about 15s) but that would be completely fine. When using MD App in play mode however, the time to complete PDF function skyrockets. Upon investigating the network traffic that happens when the PDF function runs, we have found Synchronous XHR warnings in console (since the PDF function worked on our first try I cannot tell is those warnings are new or not). Another interesting finding is that sometimes there can be some Fluid Relay requests when creating the PDF which I had no luck trying to find out what they might be, the URL of those is always something similar to this wss://alfred.northeurope-6.fluidrelay.azure.com/socket.io/?documentId=e138e7ac-4c55-473c-89a3-43435f4d4d5c&tenantId=a58db88d-76b2-4983-8a4c-fe50824556d4&EIO=4&transport=websocket.
What we've tried:
- Image component with base64 string of image
- HTML text component with img tag with src set to base64 of image
What we're going to try:
There is one more option left which we did not try, and that is to convert the custom page into standalone canvas app to be able to monitor the app and see if the behavior is the same (monitor for MD apps currently does not work). But before we spend another hours trying to get the experimental PDF function to work, I thought why not ask, maybe someone is facing the same issue or some insider is going to answer.
So please, can someone from the PDF function team explain what is happening here and how are we supposed to work with pictures?