0
A
回答
1
答案是NO,你不能除非你写自己的解决方案。报告查看器控件不支持这一点。您的选择是创建自定义打印解决方案,或者操作RDLC文件以手动修改设置。
如果决定即时修改RDLC文件,需要将RDLC文件加载到内存中,修改XML文件以指定新的页面设置,然后在报告查看器中重新加载RDLC文件。
如果您决定做手工印刷,这里是一些VB.NET代码,以帮助您入门:
Dim m_pageSettings As PageSettings 'Stores page settings for printout
Dim m_currentPage As Integer 'Used for index of pages
Private m_pages As New List(Of Stream)() 'Stores a stream for each pages
'Event fires when printDocument starts printing - reset page index to zero
Private Sub PrintDocument1_BeginPrint(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
m_currentPage = 0
End Sub
'Function that prints all the pages included in the report
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim pageToPrint As Stream = m_pages(m_currentPage)
pageToPrint.Position = 0
Dim pageMetaFile As Metafile = New Metafile(pageToPrint) 'create an image(metafile) of the report page
Using (pageMetaFile)
'Create a rectangle the size of our report - include margins
' Dim adjustedRect As Rectangle = New Rectangle(_
' e.PageBounds.Left - CType(e.PageSettings.HardMarginX, Integer), _
' e.PageBounds.Top - CType(e.PageSettings.HardMarginY, Integer), _
' e.PageBounds.Width, _
' e.PageBounds.Height)
Dim adjustedRect As Rectangle = New Rectangle(_
e.PageBounds.Left, _
e.PageBounds.Top, _
e.PageBounds.Width, _
e.PageBounds.Height)
e.Graphics.FillRectangle(Brushes.White, adjustedRect) 'Fill rectangle with WHITE background
e.Graphics.DrawImage(pageMetaFile, adjustedRect) 'Draw report in rectangle - this will be printed
m_currentPage = m_currentPage + 1
e.HasMorePages = m_currentPage < m_pages.Count 'If more pages are left - keep processing
End Using
End Sub
'Event fires when PrintDocument queries for PageSettings. Return a copy of m_pagesettings.
Private Sub PrintDocument1_QueryPageSettings(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.QueryPageSettingsEventArgs) Handles PrintDocument1.QueryPageSettings
e.PageSettings = CType(m_pageSettings.Clone, PageSettings)
End Sub
'Render the report in a EMF - This function creates metafiles(images) of each page in the report
Private Sub RenderAllLocalReportPages(ByVal localReport As LocalReport)
Dim deviceInfo As String = CreateEMFDeviceInfo() 'Enhanced MetaFile
Dim warnings As Warning() = Nothing
m_pages.Clear()
localReport.Render("IMAGE", deviceInfo, AddressOf LocalReportCreateStreamCallback, warnings)
End Sub
'Callback function used with RenderAllLocalReportPages
Private Function LocalReportCreateStreamCallback(ByVal name As String, ByVal extension As String, ByVal encoding As Encoding, ByVal mimeType As String, ByVal willSeek As Boolean) As Stream
Dim stream As New MemoryStream()
m_pages.Add(stream)
Return stream
End Function
Private Function CreateEMFDeviceInfo() As String
Dim paperSize As PaperSize = m_pageSettings.PaperSize
Dim margins As Margins = m_pageSettings.Margins
'The device info string defines the page range to print as well as the size of the page.
'A start and end page of 0 means generate all pages.
Return String.Format(CultureInfo.InvariantCulture, "<DeviceInfo><OutputFormat>emf</OutputFormat><StartPage>0</StartPage><EndPage>0</EndPage><MarginTop>{0}</MarginTop><MarginLeft>{1}</MarginLeft><MarginRight>{2}</MarginRight><MarginBottom>{3}</MarginBottom><PageHeight>{4}</PageHeight><PageWidth>{5}</PageWidth></DeviceInfo>", ToInches(margins.Top), ToInches(margins.Left), ToInches(margins.Right), ToInches(margins.Bottom), ToInches(paperSize.Height), ToInches(paperSize.Width))
End Function
'Convert report printing size to inches
Private Shared Function ToInches(ByVal hundrethsOfInch As Integer) As String
Dim inches As Double = hundrethsOfInch/100.0R
Return inches.ToString(CultureInfo.InvariantCulture) & "in"
End Function
希望这有助于。
相关问题
- 1. 更改打印机设置
- 2. 更改vb.net中的打印机设置
- 3. 打印报告时设置可见性
- 4. 如何在qweb报告中打印时间时更改时区?
- 5. POS打印机的Flex报告打印
- 6. 在android上运行并打印报告
- 7. 在vfp报告中更改页面之前的打印行
- 8. 直接向打印机打印报告
- 9. 在c#中打印报告时更改了日期格式
- 10. 更改打印报告背景
- 11. Birt报告行式打印机支持
- 12. Jasper报告字体在点阵打印机打印时重叠
- 13. 更改水晶报表打印图像运行时的大小
- 14. 如何为报告设置特定的打印机?
- 15. 运行时设计报告
- 16. 如何在打印时设置打印机设置PDF
- 17. 修改报告中的打印数据
- 18. 条码打印条码打印机页面设置水晶报告
- 19. 打印报告
- 20. 打印报告时出错
- 21. 将默认打印机设置为更改名称的打印机
- 22. 通过命令行更改打印机设置
- 23. Microsoft Interop.Word - 更改纸张尺寸时忽略打印机设置
- 24. 在打印之前在Microsoft Access报告中运行VBA
- 25. 如何在jasper报告中设置打印excel文件
- 26. 如何在多台打印机上打印水晶报告?
- 27. 调用报告后在远程打印机上打印
- 28. SSRS报告打印在小型打印机上被压扁
- 29. 在运行时更改CoreNLP设置
- 30. django:在运行时更改设置
thanx对此可能会有所帮助 – 2009-09-02 17:06:28