2014-01-30 5 views
3

가로 또는 세로로 로컬 보고서를 인쇄하려고합니다. 미리보기없이 rdlc에서 가로/세로 인쇄

private void Export(LocalReport report) 
{ 
    Warning[] warnings; 
    m_streams = new List<Stream>(); 

    var deviceInfo = new StringBuilder(); 
    deviceInfo.AppendLine("<DeviceInfo>"); 
    deviceInfo.AppendLine("<OutputFormat>EMF</OutputFormat>"); 
    //"11.7in", "8.3in" 
    deviceInfo.AppendLine("<PageWidth>11.7in</PageWidth>"); 
    deviceInfo.AppendLine("<PageHeight>8.3in</PageHeight>"); 

    deviceInfo.AppendLine("</DeviceInfo>"); 

    report.Render("Image", deviceInfo.ToString(), CreateStream, out warnings);    
    foreach (var stream in m_streams) { stream.Position = 0; } 
} 

나는 2 개 개의 다른 보고서 세로 모드 일 및 가로 모드에서 하나를 가지고 있지만, 나는 그것의 항상 세로로 인쇄, 페이지 폭 및 페이지 크기에 대한 변경 값 중요하지 않습니다. 11.7in과 8.3in 사이에서 너비와 높이를 바꾸었지만 항상 세로 모드로 인쇄했습니다.

답변

0

ReportPageSettings.IsLandscape 속성을 사용하여 보고서가 가로로 정의되어 있는지 확인할 수 있습니다 (보고서 속성> 페이지 설정> 방향).

가로 방향 인 경우 DeviceInfo 선언에서 용지 너비와 용지 높이를 바꿔야합니다. 당신이 사용하는 경우

Dim rdlLocalReport As New LocalReport 
Dim strDeviceInfo As String 

With rdlLocalReport.GetDefaultPageSettings 

    Dim intPaperSizeWidth As Integer = 0 
    Dim intPaperSizeHeight As Integer = 0 

    If .IsLandscape Then 
     intPaperSizeWidth = .PaperSize.Height 
     intPaperSizeHeight = .PaperSize.Width 
    Else 
     intPaperSizeWidth = .PaperSize.Width 
     intPaperSizeHeight = .PaperSize.Height 
    End If 

    strDeviceInfo = "<DeviceInfo>" _ 
     & "<OutputFormat>EMF</OutputFormat>" _ 
     & "<PageWidth>" & Strings.Replace(intPaperSizeWidth/100, ",", ".") & "in</PageWidth>" _ 
     & "<PageHeight>" & Strings.Replace(intPaperSizeHeight/100, ",", ".") & "in</PageHeight>" _ 
     & "<MarginTop>" & Strings.Replace(.Margins.Top/100, ",", ".") & "in</MarginTop>" _ 
     & "<MarginLeft>" & Strings.Replace(.Margins.Left/100, ",", ".") & "in</MarginLeft>" _ 
     & "<MarginRight>" & Strings.Replace(.Margins.Right/100, ",", ".") & "in</MarginRight>" _ 
     & "<MarginBottom>" & Strings.Replace(.Margins.Bottom/100, ",", ".") & "in</MarginBottom>" _ 
     & "</DeviceInfo>" 

End With 

PrintDocument 당신은 또한 그에 따라 PageSettings.Landscape 속성을 변경해야합니다.

Dim printDoc As New PrintDocument 
printDoc.DefaultPageSettings.Landscape = rdlLocalReport.GetDefaultPageSettings.IsLandscape