Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion java/src/main/java/com/genexus/webpanels/GXWebReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public abstract class GXWebReport extends GXWebProcedure
protected int gxYPage;
protected int Gx_page;
protected String Gx_out = ""; // Esto est� asi porque no me pude deshacer de una comparacion contra Gx_out antes del ask.
protected String filename;
protected String filetype;

public GXWebReport(HttpContext httpContext)
{
Expand All @@ -45,14 +47,19 @@ protected void initState(ModelContext context, UserInformation ui)
protected void preExecute()
{
httpContext.setContentType("application/pdf");
httpContext.getResponse().addHeader("content-disposition", "inline; filename=" + getClass().getSimpleName() + ".pdf");
httpContext.setStream();

// Tiene que ir despues del setStream porque sino el getOutputStream apunta
// a otro lado.
((PDFReportItext) reportHandler).setOutputStream(httpContext.getOutputStream());
}

protected void setOutputFileName(String outputFileName){
filename = outputFileName;
}
protected void setOutputType(String outputType){
filetype = outputType.toLowerCase();
}
private void initValues()
{
Gx_line = 0;
Expand Down Expand Up @@ -98,6 +105,7 @@ protected boolean initPrinter(String output, int gxXPage, int gxYPage, String in
{
int x[] = {gxXPage};
int y[] = {gxYPage};
setResponseOuputFileName();

getPrinter().GxRVSetLanguage(localUtil._language);
boolean ret = getPrinter().GxPrintInit(output, x, y, iniFile, form, printer, mode, orientation, pageSize, pageLength, pageWidth, scale, copies, defSrc, quality, color, duplex);
Expand All @@ -108,6 +116,12 @@ protected boolean initPrinter(String output, int gxXPage, int gxYPage, String in
return ret;
}

private void setResponseOuputFileName(){
String outputFileName = filename!=null ? filename : getClass().getSimpleName();
String outputFileType = filetype!=null ? "." + filetype.toLowerCase(): ".pdf";
httpContext.getResponse().addHeader("content-disposition", "inline; filename=" + outputFileName + outputFileType);
}

protected void endPrinter()
{
getPrinter().GxEndPrinter();
Expand Down