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
250
WebGridDocumentExporter
posted

Hi Mike,

Kindly Provide the soln of the problem explained in the attached doc file.

Its urgent.

 

  • 250
    posted

    Following is the code for report printing.

    protected void UltraWebGridDocumentExporter1_BeginExport(object sender, DocumentExportEventArgs e)
        {
            // Add a title to the report
            ReportText.IText heading = e.Section.AddText();
            ReportText.Style headingStyle = new ReportText.Style(new    Infragistics.Documents.Graphics.Font("Tahoma", 16), Infragistics.Documents.Graphics.Brushes.Crimson);
            heading.AddContent("Activity For Specified Period ", headingStyle);
            heading.AddLineBreak();

            heading.Alignment = Infragistics.Documents.Report.TextAlignment.Center;
            heading.AddContent("Printed By: Optimal Infotech Pvt Ltd ", headingStyle);
            heading.AddLineBreak();
            heading.Margins.Bottom = 15;
           

            // Add a caption with some more information
            ReportText.IText caption = e.Section.AddText();
            ReportText.Style captionStyle = new ReportText.Style(new Infragistics.Documents.Graphics.Font("Tahoma", 12), Infragistics.Documents.Graphics.Brushes.Black);
            caption.AddContent("Buyer:", captionStyle);
            caption.AddLineBreak();
            caption.AddContent("Merchandiser:", captionStyle);
            caption.AddLineBreak();
            caption.AddContent("User:", captionStyle);
            caption.AddLineBreak();
            caption.AddContent("From Date:", captionStyle);
            caption.AddLineBreak();
            caption.AddContent("To Date:", captionStyle);
            caption.AddLineBreak();
            caption.Margins.Bottom = 15;

            // Get a reference to the section's PageNumbering object.
            Infragistics.Documents.Report.Section.PageNumbering pn = e.Section.PageNumbering;

            //Add a Footer to the report
            e.Section.PageMargins.All = 40;

            // Create a style for the page numbering font.
            pn.Style = new Infragistics.Documents.Report.Text.Style(Fonts.Arial, Infragistics.Documents.Graphics.Brushes.Black);

            // The Template property is the actual string that shows the page numbering. Use the [Page #] place-
            // holder for the current page and the [TotalPages] place-holder for the total amount of pages in the entire document.
            pn.Template = "Page [Page #] of [TotalPages]";

            // The page numbering will be aligned with the right side of the page. Valid values off the
            // Alignment enum include Left, Center, and Right.
            pn.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Right;
            // The page numbering will be located at the bottom of the page. Valid values off the Alignment enum include Top and Bottom.
            pn.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Bottom;
            // The page numbering is at the extreme bottom of the page, so we need to change the Y Offset in order to bring it in line with the rest of
            // the page footer text.
            pn.OffsetY = -18;

            Infragistics.Documents.Report.Section.ISectionFooter footer = e.Section.AddFooter();
            footer.Height = 30;
            ReportText.IText text = footer.AddText(0, -18);
            text.AddContent(string.Format("Date printed: {0}", DateTime.Now.ToString("dd-MM-yyyy")));


            // customize the grid for export
            //UltraWebGrid1.Columns.FromKey("CustomerID").Hidden = true;
                  
           
        }

    protected void btnexportpdf_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                //// configure exporter
                UltraWebGridDocumentExporter1.Format = FileFormat.PDF;
                UltraWebGridDocumentExporter1.DownloadName = "ActSpecifiedPeriod.pdf";
                UltraWebGridDocumentExporter1.TargetPaperOrientation = PageOrientation.Landscape;
                       
                UltraWebGridDocumentExporter1.ExportMode = Infragistics.WebUI.UltraWebGrid.Exporter.ExportMode.Download;
                UltraWebGridDocumentExporter1.AutoSizeRows = Infragistics.WebUI.Shared.DefaultableBoolean.True;
                // trigger export
                UltraWebGridDocumentExporter1.Export(grdActSpecifiedgrid);

             
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

        }