1

With a Genexus procedure, setting the call protocol to Http and the output_file rule, you can create a report and show to the user a pdf, basic Genexus tool. My problem is that I can't set the name of this pdf, it ignores the parameter of the output_file rule and if I try to save the pdf manually, it's named as the name of the procedure.

Can I set the name of the pdf somehow? Better if I can send it as parameter

Nicola
  • 209
  • 1
  • 8

3 Answers3

1

Add this code to the procedure.

// &DocumentFriendlyName is varchar(100) 
&HttpResponse.AddHeader(!"Content-Type", !"application/pdf")
&HttpResponse.AddHeader(!"Content-Disposition", !"attachment;filename=" + &DocumentFriendlyName + !".pdf")
ealmeida
  • 444
  • 3
  • 11
  • Almost, but not a solution for me since with this code I am asked to save the file as soon as I open it while for me the best option would be that the file is first opened in the browser and downloaded only later, at the user's will – Nicola Jan 27 '23 at 13:36
-1

If you don't want to download the PDF directly, create the PDF on the server, then use a &Window object to show it.

&Window.Url = &DownloadPdfUrl
&Window.Open()
Sergio
  • 122
  • 4
-1

If you add the rule:

Output_file(&FileName, 'PDF');

It does not generate the file with the value of the variable &FileName?

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
  • It does not work. If the procedure has call protocol Internal, the pdf file is created correctly with what is contained in that rule, but if the option is set to HTTP and the file is opened in the browser that name is ignored – Nicola Jan 31 '23 at 07:53
  • Ok, in that case I would put the procedure in Internal and generate the file in PublicTempStorage and then redirect the user to the application URL + PublicTempStorage/FileName.pdf – Guillermo Gandolfo Jan 31 '23 at 12:29