none
ReportViewer (Framework 2.0): Hyperlink in print layout RRS feed

  • Question

  • Hi,

    I developed a few reports for a windows app. for our client using rdlc. The reports are in local processing mode. Our client after viewing the prototype made the following comments

    1) The reports in normal layout do not look good. The report should always be displayed in print layout

    2) Instead of the default toolbar, a custom toolbar and context menu

    3) Automatic font size adjustment for currency columns for broad contents so that contents do not flow on next line.

    For 2) above, I have been able to provide all functionalities of the default toolbar via custom toolbar and context menu except for 'Next' button in Print Layout. There is no property available to get the total number of pages in Print Layout. So if you set the CurrentPage +=1  without checking for the number of pages, you will get 'Object Reference ...' error when total number of printable pages are exceeded. What is the work around ?

    For 3) I am digging into the RDLC report and trying to implement a custom algorithm that checks the width of the maximum string for the column in inches against the width of the column and set the font size of the column accordingly. Wonder if there is an easier way!

    However 1) is the biggest hindrance. My report has hyperlinks which are not shown when report is in Print Layout. I am now digging into the ReportViewer Control and trying to extend the ReportViewer to show hyperlinks in Print Layout. However I have not able to make any progress. Is it possible to enable hyperlinks in Print Layout with or without extending the ReportViewer Class ?

    I have learnt that Report Viewer Controls in Visual Studio 2010 come with extended features which may help my cause.

    Is it possible to integrate the ReportViewer Controls for Visual Studio 2010 with Visual Studio 2005 ?

    &=1
    Wednesday, February 11, 2009 6:17 AM

All replies

  • Hi devanalyst,

    I will try and help you out.

    1. Print layout uses image rendering, which adheres to different properties then the normal layout. Normal layout we call soft page, which basically means the report can grow based on content. For image, or hard page rendering, there are strict rules about the page size and margins that apply.

    You can make normal layout look more like print layout by setting properties on the rdlc file. Manage the body, margin and page sizes to help make this better. You can also modify the can grow options on the tables\matrixes.

    You cannot set hyperlinks in print mode. This is behavior that cannot be programmatically controlled by the report control. The rendering extension that creates the content on display controls this behavior(You could possibly parse the EMF content and add the links, but I do not know how you would do that).

    2. Customer toolbar is a good solution. Take a look at the following link to help you figure out the number of pages. http://www.csharphelp.com/archives3/archive545.html

    3. Hopefully you are handling this through RDL expressions. Not easy, but doable. http://msdn.microsoft.com/en-us/library/ms159238.aspx

    The Dev10 report controls will not be supported with VS 2005. You can try it out, but it would be unsupported.


    Brad Syputa, Microsoft Reporting Services This posting is provided "AS IS" with no warranties.
    Wednesday, February 11, 2009 8:56 PM
  • Brad Syputa said:

    2. Customer toolbar is a good solution. Take a look at the following link to help you figure out the number of pages. http://www.csharphelp.com/archives3/archive545.html


     Based on the article at this site and other related articles on other msdn sites, I have come up with the following code

    Function GetNumberOfPrintablePages() As Integer  
     
    Dim intNumOfPrintablePages As Integer = 0 
     
    Dim warnings As Microsoft.Reporting.WinForms.Warning() = Nothing  
     
    Dim streamids As String() = Nothing  
     
    Dim mimeType As String = Nothing 
     
    Dim encoding As String = Nothing 
     
    Dim extension As String = Nothing 
     
    Dim deviceInfo As String  
     
    Dim bytes As Byte()  
     
    Dim strPrintFormat As String = "PDF" 
    'Dim strPrintFormat As String = "IMAGE" 
    Dim strWarnings As String = "" 
     
    'deviceInfo = "<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>" 
     
    'deviceInfo = "<DeviceInfo><OutputFormat>PDF</OutputFormat></DeviceInfo>" 
     
    deviceInfo = "<DeviceInfo><OutputFormat>EMF</OutputFormat></DeviceInfo>" 
     
    bytes = ReportViewer1.LocalReport.Render(strPrintFormat, Nothing, _  
     
    mimeType, encoding, extension, streamids, warnings)  
     
    'bytes = ReportViewer1.LocalReport.Render(strPrintFormat, deviceInfo, _  
     
    ' mimeType, encoding, extension, streamids, warnings)  
     
    'debug  
     
    'Dim fs As New IO.FileStream("c:\output.pdf", IO.FileMode.Create)  
     
    'fs.Write(bytes, 0, bytes.Length)  
     
    'fs.Close()  
     
    'debug  
     
    intNumOfPrintablePages = streamids.Length + 1  
     
    MessageBox.Show(streamids.Length + 1)  
     
    Return intNumOfPrintablePages  
     
    End Function  
     
     

    However it returns 1 no matter what the number of printable pages. I tried different permutations and combinations for device info as well as the format. To verify, I wrote the byte stream to a file and I find the file has the correct number of pages as shown in the reportviewer. I called this function at different points, at form load immediately after refresh report, on click of button, on change of layout but it always returns 1. Am I overlooking something ?


    Note: I am using RDLC in Local Processing Mode and developing the reports for a Windows Application


    &=1
    Thursday, February 12, 2009 7:50 AM
  • Hi,

    There is a problem with the Normal Layout. If you set the margins from the Report Properties, say 0.5in Right; 0.5 Left , the contents of the report always 'stick ' to the left side. Only in the Print Layout the contents of the report are set as per the margins.
    Is there any way so that report is displayed as per set margins in Normal Layout also ? I know that in Normal ('Soft') layout, the contents can expand both horizontally and vertically. But can we have atleast look like margins are set ?


    &=1
    Thursday, February 26, 2009 1:25 PM