[Ultimate PDF] Ultimate pdf

Forge Component
(14)
Published on 23 May by Leonardo Fernandes
14 votes
Published on 23 May by Leonardo Fernandes

Hi,

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.


Thanks,

Sushmita

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

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

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