By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,080 Members | 1,817 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,080 IT Pros & Developers. It's quick & easy.

Empty path name is not legal.

P: 37
I'm not really sure I'm going about my problem the right way or not. What I want to to is have a save button, bring up the save dialog, and save a report from reportViewer(.rdlc) in .pdf format.

The only this is, I don't show the user the dialog for previewing the report, so I can't access any of that functionality, and I know that already has an export to pdf function.

I need to do this without the use of those features. Any suggestions or ideas would be a great help!

Here is some code...

private void saveButton_Click(object sender, EventArgs e)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string fileNameExtension;

byte[] bytes = reportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streamids, out warnings);
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.Filter = "Text Files|*.txt|All Files|*.*";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
File.WriteAllBytes(saveFile.FileName, bytes);
}





Katie
Jan 23 '07 #1
Share this Question
Share on Google+
6 Replies


P: 86
This may help you accomplish this task: http://forums.microsoft.com/MSDN/Sho...39828&SiteID=1
Jan 23 '07 #2

kenobewan
Expert 2.5K+
P: 4,871
Here is another article that may help. Halfway through it has a tip on how to export to pdf without preview:
How to create local reports RDLC featuring barcode images in ASP.NET
Jan 23 '07 #3

P: 37
Thank you both!

The only problem is, is that I am using a localreport, not a server.. I really dont understand what or how I am supposed to do this. I can save the file as pdf but it gets damaged and then nothing opens.

I also can't access this code below... I don't know if it's because I am doing this differentlyor not..

Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=sample."+extension);
Response.BinaryWrite(bytes);
Response.Flush();

OK, another question...
Do pdf files have to be written/created in a different manor than rtf's, txts, and doc files? Is that my problem?
Jan 25 '07 #4

P: 86
The code I sent you was for an ASP.NET project. If you're in Windows forms, check out the following link about printing reports without the ReportViewer:

http://forums.microsoft.com/MSDN/Sho...22277&SiteID=1

There is indeed a difference in the pdf file format vs. txt, rtf, etc. The pdf format is copyrighted by Adobe, and therefore your average Joe can't just up and create a PDF. The link above, however, I think will help you solve this.

Thank you both!

The only problem is, is that I am using a localreport, not a server.. I really dont understand what or how I am supposed to do this. I can save the file as pdf but it gets damaged and then nothing opens.

I also can't access this code below... I don't know if it's because I am doing this differentlyor not..

Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=sample."+extension);
Response.BinaryWrite(bytes);
Response.Flush();

OK, another question...
Do pdf files have to be written/created in a different manor than rtf's, txts, and doc files? Is that my problem?
Jan 25 '07 #5

P: 37
I'll take a look at that page. I thought maybe I'd have to add a reference to an adobe dll.
Thanks a lot, I hope this helps!
Jan 25 '07 #6

P: 37
I'll take a look at that page. I thought maybe I'd have to add a reference to an adobe dll.
Thanks a lot, I hope this helps!

Turns out there's a bug in VS when you have an image attatched to the report..
Jan 26 '07 #7

Post your reply

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