Export .rdlc report to pdf in Landscape mode

user3923437 picture user3923437 · Aug 19, 2014 · Viewed 10.5k times · Source

My report properties are set to Width 11in and Height 8.5in. My body properties are set to Width 10in and Height 7.5in and the margins are 0, but the report always displays in portrait mode. The person who coded the page is using a reportviewer control inside of an aspx page which is being popped up from a JavaScript pop window writing the response to a pdf. If the report is opened in the report viewer it is landscape like expected. Any ideas anyone?

Answer

Er Mayank picture Er Mayank · Aug 19, 2014

width, height and orientation of a Report (.rdlc) depends on the two factors :

  1. What page settings are applied on the report. We can set orientation to landscape by opening reportSelect Report and Orientation in Solution Explorer

  2. Adding Some line of codes to define width, height and orientation.


Function SetPageSettings()
    Dim PgSet As New System.Drawing.Printing.PageSettings
    Dim Psiz As New Printing.PaperSize
    Psiz.RawKind = Printing.PaperKind.A4
    PgSet.PaperSize = Psiz
    PgSet.Landscape = False
    PgSet.Margins.Top = 60
    PgSet.Margins.Bottom = 60
    PgSet.Margins.Right = 60
    PgSet.Margins.Left = 60
    ReportViewer1.SetPageSettings(PgSet)
End Function