Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Reporting
Hi Guys
 
I am using microsoft report viewer on windows environment with *.rdlc reporting file.
 
I have a requirement to programatically export the report (invoice) into PDF and save it under a folder for later use (going to email the invoices).
 

The reporting part is fine and all working but However, I am unable to find a way to export the report programatically....done google without much luck.
 

any help would be highly appreicated as am slightly running out of time.
Posted 27-Dec-12 6:24am
Comments
OriginalGriff at 14-Feb-14 7:00am
   
Off topic:
Please stop editing spam.
This was an edict from On High: Chris tries out automated spam detection systems from time to time, and if you edit them then subsequent spam reports get attached to the edited version which contains no spammy material - this confuses the detectors and makes them useless.
Editing a question also resets its "Spam" count, which makes it last longer, and can mean that your account gets identified as the spammer if people aren't paying attention!
 
Just report it via the Red Flag (if you can see it) and / or post links in the Spam and Abuse forum:
http://www.codeproject.com/Forums/1652005/Spam-and-Abuse-Watch.aspx
And one the Protectors or Staff will delete it.
Bala Selvanayagam at 14-Feb-14 7:03am
   
Thanks & I did not know
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Bala Selvanayagam at 27-Dec-12 11:42am
   
Looks this is for web based and am looking for windows.
 
I have already tried this without much sucess
Adam R Harris at 27-Dec-12 11:53am
   
wow, could have done without the attitude. I am taking time out of my day to try and assist you, grateful is the only emotion you should attempt to convey. You did not mention that this was a windows application in your question so i had to take my best guess.
 
byte[] buffer;
using (FileStream fs = new FileStream("[Desired File Path]", System.IO.FileMode.Append){
buffer = ReportViewer.ServerReport.Render("pdf", null, null, null, null, null, null);
fs.write(buffer, 0, buffer.length);
fs.close();
}
Bala Selvanayagam at 27-Dec-12 12:28pm
   
Thanks Adam,
 
Apologies, if i have upset you in any means. I was struggling on this for last 4-5 hours without luck and hence my comment would have been short.
 
I have tried your suggestion and the method ServerReport.Render() does not accept null as the out put paramters,
 
would be thankful, if you could dig into for me
Adam R Harris at 27-Dec-12 12:41pm
   
Take a look at the example on here: http://msdn.microsoft.com/en-us/library/ms252214(v=vs.80).aspx
Bala Selvanayagam at 27-Dec-12 14:46pm
   
Thanks, was not straight forward for the window based environment.
 
I have switched to crystal report which is relatively easier to export taking the time constraint into account - this resolves the issue for the time being
Adam R Harris at 27-Dec-12 15:58pm
   
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
string deviceInfo;
byte[] buffer;
using (FileStream fs = new FileStream("[Desired File Path]", System.IO.FileMode.Append){
buffer = ReportViewer.ServerReport.Render("pdf", null, out mimeType, out encoding, out extension, out streamids, out warnings);
fs.write(buffer, 0, buffer.length);
fs.close();
}
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Bala Selvanayagam at 27-Dec-12 15:29pm
   
Thanks ridoy and will have a look
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

For writing of PDF, you can use iText, more exactly, its .NET port called iTextSharp:
http://en.wikipedia.org/wiki/IText[^],
http://itextpdf.com/[^],
http://sourceforge.net/projects/itextsharp/[^].
 
I provided links to iText, too, because nearly all documentation you need to work with iTextSharp is there, provided as Java documentation.
 
—SA
  Permalink  
Comments
Bala Selvanayagam at 28-Dec-12 3:54am
   
Thanks - SA
 
very much useful, thanks again
Sergey Alexandrovich Kryukov at 28-Dec-12 4:24am
   
You are welcome. If so, please accept the answer formally (green button) — thanks.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 BillWoodruff 173
3 Sergey Alexandrovich Kryukov 170
4 PIEBALDconsult 160
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100