1. #1
    Sencha User
    Join Date
    Apr 2011
    Location
    Surat, Gujarat, India
    Posts
    126
    Vote Rating
    0
    rushi2440 is on a distinguished road

      0  

    Thumbs up Unanswered: pdf download dialog window not appear in browser.

    Unanswered: pdf download dialog window not appear in browser.


    Hi.. sencha forum member i am little bit confuse in my report export process. I am able to generate the report in pdf form using jasper report and java.

    The report generated not available to be get download to the client side.
    I am generating pdf file using below code
    Code:
    public void getTaskreportPDF(Session openSession,HttpServletRequest request,
                HttpServletResponse response) {
    		try {	
    Class.forName("com.mysql.jdbc.Driver");
               Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/contact","root","root");
    			
    			Map params = getParameters(openSession);
    			Date date = new Date();
    			String reportfileName = "report"+date.getDate()+"-"+date.getMonth()+"-"+date.getYear()+"-"+date.getTime()+".pdf";
    		   JasperDesign jasperDesign = JRXmlLoader.load(this.getClass().getResourceAsStream("/com/gantt/report/ganttreport.jrxml"));
               JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
               
               JasperPrint jasperprint = JasperFillManager.fillReport(jasperReport, params,con);
           		
       		JRAbstractExporter exporterPDF = new JRPdfExporter();
               exporterPDF.setParameter(JRExporterParameter.JASPER_PRINT, jasperprint);
               exporterPDF.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
               response.setHeader("Content-Disposition", "inline;filename="+ reportfileName);
               response.setContentType("application/pdf");
               exporterPDF.exportReport();  
    		} catch(Exception exception) {
                System.out.println("Error occured " +exception.getMessage());
            }
    	}
    when i view my firebug net tab i am getting response as
    Code:
    Response Headersview source
    Content-Disposition inline;filename=report21-0-112-1327133892240.pdf
    Content-Type application/pdf
    Date Sat, 21 Jan 2012 08:18:18 GMT
    Server Apache-Coyote/1.1
    Transfer-Encoding chunked
    Request Headersview source
    Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Accept-Encoding gzip, deflate
    Accept-Language en-us,en;q=0.5
    Connection keep-alive
    Cookie JSESSIONID=61B442502AEF0B8F445E4FC048FE9478; bmeval=1327129699647
    Host localhost:8085
    Referer http://localhost:8085/Gantt/
    User-Agent Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
    Request Headers From Upload Stream
    Content-Length 45
    Content-Type multipart/form-data; boundary=---------------------------181274673728
    my response is correct and i am getting the pdf file having size of 4 kb. but the problem is that the download dialog window is not available. so help me to find my problem so I can solve it.

    my app.js is
    Code:
    Ext.onReady(function() {
        Ext.QuickTips.init();
        
        App.init();
    });
    
    
    TaskPriority = {
        Low : 0,
        Normal : 1,
        High : 2
    };
    
    
    App = {
    
    
        // Initialize application
        init: function () {
    	
    	//create the downloadframe at the init of your app
    	this.downloadFrame = Ext.getBody().createChild({
    	                tag: 'iframe'
    	                    , cls: 'x-hidden'
    	                    , id: 'iframe'
    	                    , name: 'iframe'
    	            });
    	//create the downloadform at the init of your app
    
    
    	            this.downloadForm = Ext.getBody().createChild({
    	                tag: 'form'
    	                    , cls: 'x-hidden'
    	                    , id: 'form'
    	                    , target: 'iframe'
    	            });
    	            
    	   
            var params = new Object();
            
            var g = Ext.create("Gnt.panel.Gantt", {
                height: '100%',
                width: '99%',
                renderTo: Ext.getBody(),
                leftLabelField: 'Name',
                loadMask: true,
                startDate: start,
                endDate: end,
                multiSelect : true,
                cascadeChanges : true,
                viewPreset: 'weekAndDayLetter',
                recalculateParents: false,
               
    		   tbar: [{
                    	iconCls : 'icon-pdf',
                        scale : 'large', 
                        text : 'Export to PDF',
                        handler : function(button, event){
                    	   //code goes here
                    	   Ext.Ajax.request({
                    		   url: 'task/GetTaskReportPDF.action',
                    		   params: params,
                               form: App.downloadForm,
                               isUpload: true,
                    		  // method: 'POST',                			   
    	                		success : function(response, option){
    	                			//this.gestioneRisposta(response);
    	                		      console.log("success");
    	                		}
    	                		,failure :function(response, option){
    	                			console.log("failure");
    	                		}
    	                		,scope : this
                    		});                	  
                      }
                    }
                ]
            });
        }
    };
    I am using Java as my server side technology and for the report i am using Jasper Report.

    Yogendra Singh
    Sr. Programmer
    Kintudesigns.com

  2. #2
    Sencha User
    Join Date
    Apr 2011
    Location
    Surat, Gujarat, India
    Posts
    126
    Vote Rating
    0
    rushi2440 is on a distinguished road

      0  

    Thumbs up


    hi.. forum member.

    I am able to get my download window that download the pdf file for me. But the problem is that the file name always comes as GetTaskReportPDF.action

    I tried to use exporterPDF.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, reportfileName); to give my file name but that also doesn't work.

    I got my solution by removing the inline from the header.

    Yogendra Singh

    Sr. Programmer

    Kintudesigns.com

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Location
    Surat, Gujarat, India
    Posts
    126
    Vote Rating
    0
    rushi2440 is on a distinguished road

      0  

    Thumbs up


    got a solution by changing the response header as

    response.setHeader("Content-disposition",
    "attachment; filename=\"" +"example.pdf" +"\"");

    thanks for your support forum members.

    Yogendra Singh
    Sr. Programmer
    Kintudesigns.com

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,501
    Answers
    13
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Why not just use a Button with an href config?

  5. #5
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    @Animal, maybe because sending params is the problem in that case. Otherwise I think thats a nice solution, less code.

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi