Empty path name is not legal.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • delusion7
    New Member
    • Sep 2006
    • 37

    Empty path name is not legal.

    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(.r dlc) 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_Clic k(object sender, EventArgs e)
    {
    Warning[] warnings;
    string[] streamids;
    string mimeType;
    string encoding;
    string fileNameExtensi on;

    byte[] bytes = reportViewer1.L ocalReport.Rend er("PDF", null, out mimeType, out encoding, out fileNameExtensi on, out streamids, out warnings);
    SaveFileDialog saveFile = new SaveFileDialog( );
    saveFile.Filter = "Text Files|*.txt|All Files|*.*";
    if (saveFileDialog 1.ShowDialog() == DialogResult.OK )
    {
    File.WriteAllBy tes(saveFile.Fi leName, bytes);
    }





    Katie
  • enreil
    New Member
    • Jan 2007
    • 86

    #2
    This may help you accomplish this task: http://forums.microsoft.com/MSDN/Sho...39828&SiteID=1

    Comment

    • kenobewan
      Recognized Expert Specialist
      • Dec 2006
      • 4871

      #3
      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

      Comment

      • delusion7
        New Member
        • Sep 2006
        • 37

        #4
        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.Conten tType = mimeType;
        Response.AddHea der("content-disposition", "attachment ; filename=sample ."+extension );
        Response.Binary Write(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?

        Comment

        • enreil
          New Member
          • Jan 2007
          • 86

          #5
          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:



          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.

          Originally posted by delusion7
          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.Conten tType = mimeType;
          Response.AddHea der("content-disposition", "attachment ; filename=sample ."+extension );
          Response.Binary Write(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?

          Comment

          • delusion7
            New Member
            • Sep 2006
            • 37

            #6
            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!

            Comment

            • delusion7
              New Member
              • Sep 2006
              • 37

              #7
              Originally posted by delusion7
              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..

              Comment

              Working...