[Html2PdfConverter] Convert to PDF in a Multi-tenant application

[Html2PdfConverter] Convert to PDF in a Multi-tenant application

  
Forge Component
(40)
Published on 24 Mar by Guilherme Pereira
40 votes
Published on 24 Mar by Guilherme Pereira
Hi,

I tried using the function in a multi-tenant environment. If i access the URL directly, my page displays the results of the query correctly. However, when I generate a pdf passing the same URL, my query does not work and my result on the page is blank.

Tried the function in a single-tenant environment and it works perfectly fine.

Any idea why?
Thanks.
I've resolved this issue.

On the pdf pages, I have to check the 'Show Tenant Identifier' option for all the entities that are used in the query. Then I'll have to input the tenantId into these pages. 

Only then will the pdf pages be able to recognise the tenant and query the data properly.

But in this case for all entities in all queries I have to add TenantId.  Standard data management of tenant doesn't work.
May be are there other solution for this issue?

The solution for this problem is the same as indicated in the OutSystems Help for "Using Web Services in Multi-Tenant Applications": http://www.outsystems.com/help/ServiceStudio/9.1/index.htm#t=Multi-tenant_eSpaces%2FUsing_Web_Services_in_Multi-Tenant_Applications.htm
I recommend the use of the option of "Explicitly Sending Tenant Information" to the URL that will be indicated in invocation of the Html2PdfConverter action GeneratePDF(), instead of "Sending User Credentials".
The URL will be something like "http://<your-server>/<your-espace>/<your-screen>.aspx?TenantId=<TenantId_Value>&<YourEntityId_Parameter>=<YourEntityId_Value>
As a final example: http://x.outsystemscloud.com/Test/TestPdf.aspx?TenantId=13&DocumentId=1234
-
You can get the value for the current Tenant in a Multi-tenant application using the Site Property (not Session Variable) "TenantId".
Then, in your web screen preparation you will invoke the system action TenantSwitch() using the parameter TenantId to change context to the correct Tenant, so you can get the correct info.

Albertas Repecka wrote:

But in this case for all entities in all queries I have to add TenantId.  Standard data management of tenant doesn't work.
May be are there other solution for this issue?
 
 


I still can't workaround this Error.


I'm starting to think that maybe it has  to  do with the app being Multi Tenant and I have a UserManager role ticked.


Can that be the cause of this error?


Could not find file 'C:\Users\ETBA59~1\AppData\Local\Temp\TEMPISJBMTXSHB00000000000000000000000000000000.pdf'.
SetProcessDpiAwareness failed: "COM error 0xffffffff80070005  (Unknown error 0x0ffffffff80070005)"
Error: Failed loading page https:// (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1, due to unknown error.


Because I tried deleting and re-uploading the exe file and run As but I don't know why its looking in the folder


'C:\Users\ETBA59~1\AppData\Local\Temp\TEMPISJBMTXSHB00000000000000000000000000000000.pdf'.


instead of %win%temp%


Isn't there another component I can use to convert html to pdf ?


I tried using the jsPDF plugin but it has so many exclusions.



The web screen that has the HTML that will converted to PDF must have the "Anonymous" role ticked, for the "wkhtmltopdf" tool to be able to access it.