asp.net - how to save crystal report that converted to pdf in asp .net -
i wrote code converts crystal report pdf, can't store pdf file automatically project.
protected void page_load(object sender, eventargs e) { crystalreportviewer1.reportsource = getreportdocument(); crystalreportviewer1.databind(); // report document reportdocument repdoc = getreportdocument(); // stop buffering response response.buffer = false; // clear response content , headers response.clearcontent(); response.clearheaders(); try { // export report response stream in pdf format , file name customers repdoc.exporttohttpresponse(exportformattype.portabledocformat, response, true, "tfa"); // there other format options available such word, excel, cvs, , html in exportformattype enum given crystal reports } catch (exception ex) { console.writeline(ex.message); ex = null; } } private reportdocument getreportdocument() { // file path crystal report string repfilepath = server.mappath("~/crystalreport1.rpt"); // declare new crystal report document object // , report file report document reportdocument repdoc = new reportdocument(); repdoc.load(repfilepath); // set datasource getting dataset business // layer , // in our case business layer getcustomerdata function return repdoc; }
exportoptions objexopt; crystalreportviewer1.reportsource = (object)getreportdocument(); crystalreportviewer1.databind(); // report document reportdocument repdoc = getreportdocument(); repdoc.exportoptions.exportformattype = exportformattype.portabledocformat; repdoc.exportoptions.exportdestinationtype = exportdestinationtype.diskfile; diskfiledestinationoptions objdiskopt = new diskfiledestinationoptions(); objdiskopt.diskfilename = @"c:\r.pdf"; repdoc.exportoptions.destinationoptions = objdiskopt; repdoc.export();
Comments
Post a Comment