none
Help in direct printing of RDLC from Windows application

    Question

  • HI,

    I implemented the code from the below mentioned link to print the RDLC report directly to the printer via C# windows application.

    http://msdn.microsoft.com/en-us/library/ms252091.aspx

    All went well till test phase, but in actual production phase, the end user don't have write permissions to any of folder (except user profile folders).

    When they are trying to print, the process tries to create EMF file in the app folder and giving the access denied error.

    Is there anyway I can overcome this..  Can we generate report layout in memory stream and directly send the stream to printer or can we specify the path to where the EMF file will be created?

    Thanks

    Varun

    Tuesday, June 22, 2010 5:27 AM

All replies

  • Hi Varun_Sharma

    You can generate pdf file by programmatically and then you can print it.

    this.reportviewer1.localReport.Render(args,args,...)

    search this code and emplment. It may be helpfull for you.

    Saturday, July 31, 2010 12:27 PM
  • In the code that you used (in the MSDN article) the function CreateStream contains the path for saving the EMF files - you can change it from here.

     

     private Stream CreateStream(string name,
       string fileNameExtension, Encoding encoding,
       string mimeType, bool willSeek)
      {
        Stream stream = new FileStream(@"..\..\" + name +
          "." + fileNameExtension, FileMode.Create);
        m_streams.Add(stream);
        return stream;
      }

     

    Also you can change FileStream to MemoryStream and here no saving of EMF file is needed at all.
    Ali Hamdar (alihamdar.com)
    Saturday, July 31, 2010 11:14 PM