none
centering tables in report layout RRS feed

  • Question

  •  Hi everyone.

     

    Can anyone help me to center table on local report.

     

    I have table in details section of list with variable number of displayed columns (6-14). Visibility property for column of the table works fine and, my table is displayed properly as data is concerned. Only problem is that every table should be centered (horizontally) on page.

     

    I try a trick to add dummy columns to fill out needed space on the left, so when one data column is hidden one dummy column on the left side of paper (with half of data column width) is visible. This produces fine layout except that my table in design mode exceeds width of the page and every second rendered page is empty.

     

    It is aspx application, and report is rdlc. I am not using ReportViewer control, but render reports directly to pdf.

     

    Is someone knows how to solve this problem (to center table or to skip empty pages) I will be grateful.

     

    Thanx!

     

    zomi

    Wednesday, May 14, 2008 1:04 PM

All replies

  • Hello,

     

    If you use code given by MSDN (http://msdn.microsoft.com/fr-fr/library/ms252172(VS.80).aspx) to print your local report in pdf, you must replace :

     

    Code Snippet

        private void PrintPage(object sender, PrintPageEventArgs ev)
        {
            Metafile pageImage =
              new Metafile(m_streams[m_currentPageIndex]);
            ev.Graphics.DrawImage(pageImage, 0, 0);

            m_currentPageIndex++;
            ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
        }

     

     

    by :

     

    Code Snippet

        private void PrintPage(object sender, PrintPageEventArgs ev)
        {
            Metafile pageImage =
              new Metafile(m_streams[m_currentPageIndex]);
            ev.Graphics.DrawImageUnscaledAndClipped(pageImage, new Rectangle(0, 0, 826, 1169); //Width and Height are in thousandth of an inch



            m_currentPageIndex++;
            ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
        }

     

    Wednesday, May 14, 2008 2:41 PM
  • I dont use that code.

     

    My pdf export code is (vb):

     

    ...

    Dim warnings As Microsoft.Reporting.WebForms.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 = "<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"

    Dim cID As Integer = Request.QueryString(0)

    Dim bytes As Byte()

    Dim lr As New Microsoft.Reporting.WebForms.LocalReport

    lr.ReportPath = "Reports\aRates.rdlc"

    AddHandler lr.SubreportProcessing, AddressOf aRatesSubreportProc

    dsBase.DataBind()

    lr.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("RateSheet_RateShBase", dsBase))

    bytes = lr.Render("PDF", deviceInfo, mimeType, encoding, extension, streamids, warnings)

    Response.ClearContent()

    Response.ClearHeaders()

    Response.ContentType = "application/pdf"

    Response.AppendHeader("Content-Disposition", "attachment; filename=""" + "RateSheet.pdf" + """")

    Response.BinaryWrite(bytes)

    Response.Flush()

    Response.Close()

    ...

     

    Idea is to export report to pdf that can be saved.

    Wednesday, May 14, 2008 10:22 PM
  • You can specifiy a device information with appropriate values, MSDN :

    Thursday, May 15, 2008 7:00 AM
  •  

    Sorry for delay on my reply.

     

    This information was helpfull in general (it is god to know appropriate values) but I try to figure out how to use it to solve my problem and still have no idea.

    Monday, May 19, 2008 11:21 PM
  • I'm also interested centering tables (vertically or horzontally) at page.

    Any idea how to archieve that?

    Rgs

    Maciej

    Wednesday, November 12, 2008 2:33 PM