none
Problem with Direct Print with Report Viewer 2010 RRS feed

  • Question

  • I directy Print a report with report Viewer 2010 on Visual studio 2010 and I found I think a bug of the report, when I export it with this code

    Private Sub Export(ByVal report As LocalReport)
        Dim deviceInfo As String = _
         "<DeviceInfo>" + _
         " <OutputFormat>PDF</OutputFormat>" + _
         " <PageWidth>8.5in</PageWidth>" + _
         " <PageHeight>11in</PageHeight>" + _
         " <MarginTop>0.25in</MarginTop>" + _
         " <MarginLeft>0.25in</MarginLeft>" + _
         " <MarginRight>0.25in</MarginRight>" + _
         " <MarginBottom>0.25in</MarginBottom>" + _
         "</DeviceInfo>"
        Dim warnings() As Warning = Nothing
        m_streams = New List(Of Stream)()
        report.Render("Image", deviceInfo, AddressOf CreateStream, _
          warnings)
    
        Dim stream As Stream
        For Each stream In m_streams
          stream.Position = 0
        Next
      End Sub

    the export change the CultureInfo of my application, this behaviour never had when I work with Visual Studio 2008 (I upgrade the solution just some days ago). I check that if I make the preview instead direct print never happen, instead if I use the code before to print the Application.CurrentCulture change, before the print I have {it-IT} after I have {us-US}.

     

    • Moved by Ji.Zhou Friday, August 6, 2010 6:53 AM move to the proper forum to get better response (From:Visual Basic General)
    Thursday, August 5, 2010 1:14 PM

Answers

  • This seems a known issue, http://social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/d1d3ada6-53fa-4484-8a50-cfec9b13a5b9.

    You may refer to the workaround that Rex used to reset the System.Threading.Thread.CurrentCulture in the RenderingBegin and RenderingComplete events.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Monday, August 9, 2010 10:45 AM
    Moderator
  • Hello,

    this.reportViewer1.RefreshReport();
    
        //Page settings for PDF File.
        string mimeType;
        string encoding;
        string extension;
        string deviceInfo =
        "<DeviceInfo>" +
        " <OutputFormat>EMF</OutputFormat>" +
        " <PageWidth>8.5in</PageWidth>" +
        " <PageHeight>10.5in</PageHeight>" +
        " <MarginTop>0.05in</MarginTop>" +
        " <MarginLeft>0.05in</MarginLeft>" +
        " <MarginRight>0.05in</MarginRight>" +
        " <MarginBottom>0.05in</MarginBottom>" +
        "</DeviceInfo>";
    
        string[] streamids;
        Microsoft.Reporting.WinForms.Warning[] warnings;
    
        //Gives byte[] of Generated pdf file.
        byte[] bytes = reportViewer1.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
    
        //System.Diagnostics.Process.Start(@"C:\Users\Hirenb\Desktop\new.pdf");
        return bytes;

     

    Now Write bytes to file and save the file as pdf file.

    EX:

    FileStream fs = new FileStream("D:\myFile.pdf",FileMode.Create,FileAccess.Write);

    fs.Write(bytes,0,(int)bytes.Length);

    fs.close();

    Now open this file using Process.

    EX:

    System.Diagnostics.Process.Start(@"D:\myFile.pdf");

    Best Of Luck

    Regards,

    Hiren Bharadwa

     

    To directly print Report as PDF file use this code. It surely helps u.

    Wednesday, August 11, 2010 11:33 AM

All replies

  • This seems a known issue, http://social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/d1d3ada6-53fa-4484-8a50-cfec9b13a5b9.

    You may refer to the workaround that Rex used to reset the System.Threading.Thread.CurrentCulture in the RenderingBegin and RenderingComplete events.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Monday, August 9, 2010 10:45 AM
    Moderator
  • Hello,

    this.reportViewer1.RefreshReport();
    
        //Page settings for PDF File.
        string mimeType;
        string encoding;
        string extension;
        string deviceInfo =
        "<DeviceInfo>" +
        " <OutputFormat>EMF</OutputFormat>" +
        " <PageWidth>8.5in</PageWidth>" +
        " <PageHeight>10.5in</PageHeight>" +
        " <MarginTop>0.05in</MarginTop>" +
        " <MarginLeft>0.05in</MarginLeft>" +
        " <MarginRight>0.05in</MarginRight>" +
        " <MarginBottom>0.05in</MarginBottom>" +
        "</DeviceInfo>";
    
        string[] streamids;
        Microsoft.Reporting.WinForms.Warning[] warnings;
    
        //Gives byte[] of Generated pdf file.
        byte[] bytes = reportViewer1.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
    
        //System.Diagnostics.Process.Start(@"C:\Users\Hirenb\Desktop\new.pdf");
        return bytes;

     

    Now Write bytes to file and save the file as pdf file.

    EX:

    FileStream fs = new FileStream("D:\myFile.pdf",FileMode.Create,FileAccess.Write);

    fs.Write(bytes,0,(int)bytes.Length);

    fs.close();

    Now open this file using Process.

    EX:

    System.Diagnostics.Process.Start(@"D:\myFile.pdf");

    Best Of Luck

    Regards,

    Hiren Bharadwa

     

    To directly print Report as PDF file use this code. It surely helps u.

    Wednesday, August 11, 2010 11:33 AM