Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Display Image in Header while exporting WinGrid to PDF or Excel formats
posted

I have been trying to display an image in the header section along with the text whenever the report is exported to excel or pdf format.

This is the function I am using for PDF Export.

Private Sub PDFExport()


        ' Create the main Section and add 50 pixels of padding on each edge.

        Dim section1 As Infragistics.Documents.Report.Section.ISection = report.AddSection()

        section1.PagePaddings.Left = 0

        section1.PagePaddings.Right = 0


        Dim sectionHeader As Infragistics.Documents.Report.Section.ISectionHeader = section1.AddHeader()

        sectionHeader.Repeat = True

        sectionHeader.Height = 100


        Dim stationeryText As Infragistics.Documents.Report.Text.IText = sectionHeader.AddText(0, 50, 0)

        stationeryText.Style = New Infragistics.Documents.Report.Text.Style(New Infragistics.Documents.Graphics.Font("Verdana", 12), Infragistics.Documents.Graphics.Brushes.Teal)

        stationeryText.Alignment = New TextAlignment(Alignment.Left)

        stationeryText.AddContent("Customer Details")


        Dim sectionHeaderText As Infragistics.Documents.Report.Text.IText = sectionHeader.AddText(0, 0)

        sectionHeaderText.Paddings.All = 0

        sectionHeaderText.Alignment = New TextAlignment(Alignment.Left, Alignment.Middle)

        sectionHeaderText.Height = New RelativeHeight(50)

        sectionHeaderText.AddContent(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString())


        Dim sectionFooter As Infragistics.Documents.Report.Section.ISectionFooter = section1.AddFooter()

        sectionFooter.Repeat = True

        sectionFooter.Height = 50


        Dim sectionFooterText As Infragistics.Documents.Report.Text.IText = sectionFooter.AddText(0, 0)

        sectionFooterText.Paddings.All = 0

        section1.PageNumbering = New Infragistics.Documents.Report.Section.PageNumbering()

        section1.PageNumbering.Style = New Infragistics.Documents.Report.Text.Style(Infragistics.Documents.Graphics.Fonts.Arial, Infragistics.Documents.Graphics.Brushes.Black)

        section1.PageNumbering.Template = "Page [Page #] of [TotalPages]"

        section1.PageNumbering.Continue = True

        section1.PageNumbering.SkipFirst = False

        section1.PageNumbering.Alignment = Infragistics.Documents.Report.PageNumberAlignment.Right

        section1.PageNumbering.OffsetX = -10

        section1.PageNumbering.OffsetY = -30

        ugdeViewCustomer.Export(ugViewCustomer, section1)

    End Sub

 

Can anyone please help me with this issue? I need to print an image too in the header at the left side of the page. That is, first the image will be displayed in the header and then the text will come alongside.

Thanks and Regards.

  • 469350
    Offline posted

    Hi,

    What part of this are you having trouble with?

    What I would do is add a grid to your sectionHeader object (using the AddGrid method). You could add two columns into the grid, then add a single row. In the first cell, you can export the image and in the second cell, you can export the text you want.