Visual webgui Report-export to PDF

Source: Internet
Author: User

The process of exporting reports in visual webgui is really different from that in webform. However, the solution is found in the visual webgui forum. Httpresponse is the same, but visual webgui requires its own method. Otherwise, the final export is only a lot of garbled code displayed on the page.

This is the link to the solution described in the Forum: Visual webgui Forum

The following section excerpt (the last post of the above link ,. In this example, we will take a look at the report control rdlc that comes with Visual Studio.

The form which tries to open the PDF file must be a gizmox Gateway Control ("igatewaycontrol") so it will handle the file writing response disconected from webgui's main response. in order to solve your problem, implement the gizmox. webgui. common. interfaces. igatewaycontrol interface as follow:

 

 Public   Class Form1: form, igatewaycontrol {Public Form1 () {initializecomponent ();} Private   Void Button#click ( Object Sender, eventargs e) {link. Open ( New Gatewayreference ( This , "Open" ));} # Region Igatewaycontrol members Public Igatewayhandler getgatewayhandler (icontext objcontext, String Straction) {localreport local = New Localreport (); Local. reportpath = context. server. mappath ( "~ /Report1.rdlc" ); Dataset1 dataset = New Dataset1 (); dataset1tableadapters. tabla1tableadapter adapter = New Webguiapplication1.dataset1tableadapters. tabla1tableadapter (); Adapter. Fill (Dataset. tabla1); reportdatasource datasource = New Reportdatasource ( "Datasetasktabla1" , Dataset. tabla1); Local. CES. Add (datasource ); String Reporttype = "Pdf" ; String Mimetype ="Application/pdf" ; String Encoding; String Filenameextension; // The deviceinfo settings shocould be changed based on the reporttype              // Http://msdn2.microsoft.com/en-us/library/ms155397.aspx              String Deviceinfo = "<Deviceinfo>" + "<Outputformat> pdf </outputformat>" + "<Pagewidth> 8.5in </pagewidth>" + "<Pageheight> 11in </pageheight>" +"<Margintop> 0.5in </margintop>" + "<Marginleft> 1In </marginleft>" + "<Marginright> 1In </marginright>" + "<Marginbottom> 0.5in </marginbottom>" + "</Deviceinfo>" ; Warning [] warnings; String [] Streams; Byte [] Renderedbytes; // Render the report Renderedbytes = Local. Render (reporttype, deviceinfo, Out Mimetype, Out Encoding, Out Filenameextension, Out Streams, Out Warnings ); // Clear the response stream and write the bytes to the outputstream              // Set content-disposition to "attachment" so that user is prompted to take an action              // On the file (open or save) Httpresponse objresponse = This . Context. httpcontext. response; objresponse. Clear (); objresponse. clearheaders (); objresponse. contenttype = mimetype; objresponse. addheader ( "Content-disposition" , "Attachment; filename = Foo ." + Filenameextension); objresponse. binarywrite (renderedbytes); objresponse. Flush (); objresponse. End (); Return   Null ;} # Endregion }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.