@@ -24,6 +24,8 @@ public abstract class GXWebReport extends GXWebProcedure
2424 protected int gxYPage ;
2525 protected int Gx_page ;
2626 protected String Gx_out = "" ; // Esto est� asi porque no me pude deshacer de una comparacion contra Gx_out antes del ask.
27+ protected String filename ;
28+ protected String filetype ;
2729
2830 public GXWebReport (HttpContext httpContext )
2931 {
@@ -45,14 +47,19 @@ protected void initState(ModelContext context, UserInformation ui)
4547 protected void preExecute ()
4648 {
4749 httpContext .setContentType ("application/pdf" );
48- httpContext .getResponse ().addHeader ("content-disposition" , "inline; filename=" + getClass ().getSimpleName () + ".pdf" );
4950 httpContext .setStream ();
5051
5152 // Tiene que ir despues del setStream porque sino el getOutputStream apunta
5253 // a otro lado.
5354 ((PDFReportItext ) reportHandler ).setOutputStream (httpContext .getOutputStream ());
5455 }
5556
57+ protected void setOutputFileName (String outputFileName ){
58+ filename = outputFileName ;
59+ }
60+ protected void setOutputType (String outputType ){
61+ filetype = outputType .toLowerCase ();
62+ }
5663 private void initValues ()
5764 {
5865 Gx_line = 0 ;
@@ -98,6 +105,7 @@ protected boolean initPrinter(String output, int gxXPage, int gxYPage, String in
98105 {
99106 int x [] = {gxXPage };
100107 int y [] = {gxYPage };
108+ setResponseOuputFileName ();
101109
102110 getPrinter ().GxRVSetLanguage (localUtil ._language );
103111 boolean ret = getPrinter ().GxPrintInit (output , x , y , iniFile , form , printer , mode , orientation , pageSize , pageLength , pageWidth , scale , copies , defSrc , quality , color , duplex );
@@ -108,6 +116,12 @@ protected boolean initPrinter(String output, int gxXPage, int gxYPage, String in
108116 return ret ;
109117 }
110118
119+ private void setResponseOuputFileName (){
120+ String outputFileName = filename !=null ? filename : getClass ().getSimpleName ();
121+ String outputFileType = filetype !=null ? "." + filetype .toLowerCase (): ".pdf" ;
122+ httpContext .getResponse ().addHeader ("content-disposition" , "inline; filename=" + outputFileName + outputFileType );
123+ }
124+
111125 protected void endPrinter ()
112126 {
113127 getPrinter ().GxEndPrinter ();
0 commit comments