[Ultimate PDF] Ultimate pdf
Forge component by Leonardo Fernandes
Published on 08 Jan 2021


I am using ultimate pdf in reactive app for generating pdf by giving url as a parameter. My screen has some input parameters datatype as text and i am sending serialized json to the screen. It shows "An error occurred when trying to print to pdf" error. How can i solve this issue.



Rank: #147

Hello Sushmita.

I believe there's not an easy way to solve it without knowing what's going on inside the extension.

So what I usually do in those scenarios is to adapt the extension so I can output what's going on inside of it. You can do it by adding a list of text record and append to the list information along the way. But keep in mind that is necessary to adapt also the output of the async task that is generating the PDF in order to also output what's going on in there. 

Another way is to create a sample directly in Visual Studio that does the same thing as the extension and put there your URL with all the parameters and debug it or output what you need to the console.

Both approaches are valid and the goal is to understand why that logic is not handling correctly your use case. After that you can adapt the logic of the extension to overcome it.

I suspect it could be related with the size of the URL but I don't want to jump into conclusions without knowing all the facts.

Hope this helps,

Ricardo Costa

Rank: #147

Another option is to assume that in fact the size of the URL is the problem and change the logic on the OutSystems side.

Instead of sending the json as input, send a guid.

Before redirecting to the problematic screen, generate a guid, use that guid to store the data you need in the database and to retrieve the data again in the other screen.

That way the URL will be much smaller and if the size of the URL is the problem, that will solve it. 

If you proceed with this approach don't forget to add an index to the guid column in the database. And also to include a timer that will clean that entity in an off peak period. If you think the hints on that screen will be high, add a column for an is active field. That way once you consume the data associated with the guid you can on the on after fetch event set the is active to false. With that functionality you can then run the timer much more frequently and instead of deleting everything that is in the table, just delete the records that are not active.

Ricardo Costa

Rank: #5

Sushmita, make sure your URL parameters are encoded. That can be done by using the EncodeUrl() function in OutSystems.