469,076 Members | 1,502 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,076 developers. It's quick & easy.

Need help in printing the Crystal report in PDF format

hi ,

Can anybody help me in printing the Crystal report in PDF format.i.e not exporting it to PDF format.When Click preview it should be displayed in PDF
format.
May 10 '07 #1
1 1416
hi ,

Can anybody help me in printing the Crystal report in PDF format.i.e not exporting it to PDF format.When Click preview it should be displayed in PDF
format.
Hi ambel,
Try this, i exported to word and it works for me fine. Add necessary using directives or assemblies. Cheers
Expand|Select|Wrap|Line Numbers
  1. public class WebForm1 : System.Web.UI.Page
  2. {
  3. protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
  4. protected System.Web.UI.WebControls.Button Button1;
  5. private CrystalReport1 report = new CrystalReport1();
  6. private void Page_Load(object sender, System.EventArgs e)
  7. {
  8. // Put user code to initialize the page here
  9. CrystalReportViewer1.ReportSource = report;
  10. CrystalReportViewer1.Visible = true;
  11. }
  12. ......
  13.  
  14.  
  15. Now, all we need to do is to add the event handler for the export button and the code should look like this.
  16.  
  17. private void Button1_Click(object sender, System.EventArgs e)
  18. {
  19. MemoryStream oStream; // using System.IO
  20. oStream = (MemoryStream)
  21. report.ExportToStream(
  22. CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
  23. Response.Clear();
  24. Response.Buffer= true;
  25. Response.ContentType = "application/pdf"; 
  26. Response.BinaryWrite(oStream.ToArray());
  27. Response.End();
  28. }
  29.  
May 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Fuzzyman | last post: by
1 post views Thread by Stephanie Stowe | last post: by
3 posts views Thread by Colin Graham | last post: by
1 post views Thread by Maurice Mertens | last post: by
2 posts views Thread by cFleury | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.