Пример #1
0
        public void ShowRibbonPreview(IPrintable component, string title)
        {
            //HEADER
            PageHeaderArea header = new PageHeaderArea();

            header.Content.Add(string.Empty);
            header.Content.Add(title);
            header.LineAlignment = BrickAlignment.Center;
            header.Font          = new Font("Tahoma", 16, FontStyle.Bold);

            //FOOTER
            PageFooterArea footer = new PageFooterArea();

            footer.Content.AddRange(new string[] { "", "", "Página: [Page #]" });

            //UNION HEADER/FOOTER
            PageHeaderFooter headerfooter = new PageHeaderFooter(header, footer);

            PrintableComponentLink print = new PrintableComponentLink(new PrintingSystem());

            print.Component        = component;
            print.PageHeaderFooter = headerfooter;
            print.PaperKind        = PaperKind.A4;
            print.Margins          = new Margins(60, 30, 60, 60);
            print.CreateDocument();
            print.ShowRibbonPreview(this.LookAndFeel);
        }
        public static void ExportXls(GridControl gridControl1, string title)
        {
            var ps   = new PrintingSystem();
            var link = new PrintableComponentLink(ps);

            link.PaperKind = System.Drawing.Printing.PaperKind.A4Rotated;
            ps.Links.Add(link);
            link.Component = gridControl1;
            var phf = (PageHeaderFooter)link.PageHeaderFooter;

            phf.Header.Content.Clear();
            phf.Header.Content.AddRange(new[] { "", title, "" });
            phf.Header.Font          = new Font("微软雅黑", 22, FontStyle.Bold);
            phf.Header.LineAlignment = BrickAlignment.Center;
            phf.Footer.Content.Clear();
            phf.Footer.Content.AddRange(new[] { "", "", String.Format("打印时间: {0:g}", DateTime.Now) });
            phf.Footer.Font = new Font("微软雅黑", 16, FontStyle.Regular);
            link.ShowRibbonPreview(UserLookAndFeel.Default);
            var dialog = new SaveFileDialog {
                Filter = @"Excel文件|*.xls"
            };
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                ps.ExportToXls(dialog.FileName);
            }
        }
Пример #3
0
        void PreviewPrintableComponent(IPrintable component, UserLookAndFeel lookAndFeel)
        {
            PrintableComponentLink link = new PrintableComponentLink()
            {
                //MonarchEnvelope
                PrintingSystemBase = new PrintingSystemBase(),
                Component          = component,
                Landscape          = false,
                PaperKind          = PaperKind.PersonalEnvelope,
                Margins            = new Margins(2, 2, 2, 2)
            };

            link.CreateReportHeaderArea += link_CreateReportHeaderArea;
            link.ShowRibbonPreview(lookAndFeel);
        }
Пример #4
0
        void PreviewPrintableComponent(IPrintable component, UserLookAndFeel lookAndFeel)
        {
            //创建一个链接,将打印控制。
            PrintableComponentLink link = new PrintableComponentLink()
            {
                PrintingSystemBase = new PrintingSystemBase(),
                Component          = component,
                Landscape          = true,
                PaperKind          = PaperKind.A4,
                Margins            = new Margins(20, 20, 20, 20)
            };

            link.CreateReportHeaderArea += link_CreateReportHeaderArea;
            //直接通过目录保存PDF,预览
            //link.ExportToPdf(@"E:\CShapWorkSpace\XMLProcess.NET\1.pdf");
            //link.ExportToImage(@"E:\CShapWorkSpace\XMLProcess.NET\1.jpg");

            //显示报告
            link.ShowRibbonPreview(lookAndFeel);
        }
Пример #5
0
        public void CreateReport()
        {
            var link = new PrintableComponentLink(new PrintingSystem());
            link.Margins.Left = 100;
            link.Margins.Right = 100;
            link.Margins.Top = 100;
            link.Margins.Bottom = 90;
            link.PaperKind = PaperKind.A4;
            if (LoadReport == 0)
                link.Component = gridControl1;
            if (LoadReport == 1)
            {
                link.Component = gridControl2;
                link.Landscape = true;
            }

            PageFooterArea footer = new PageFooterArea();
            footer.Content.Add("Printed on " + "[Date Printed]" + " by " + Utils.Username);
            footer.LineAlignment = BrickAlignment.Near;
            PageHeaderArea header = new PageHeaderArea();
            link.CreateMarginalHeaderArea += CreateMarginalHeaderArea;
            link.PageHeaderFooter = new PageHeaderFooter(header, footer);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Save, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Watermark, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.FillBackground, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.HandTool, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Customize, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Scale, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Parameters, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SubmitParameters, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Background, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.None, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.None);
            link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Document"].Visible = false;
            link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Background"].Visible = false;
            link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Zoom"].Visible = false;
            link.CreateDocument();
            link.PrintingSystem.Document.AutoFitToPagesWidth = 1;
            link.ShowRibbonPreview(UserLookAndFeel.Default);
        }
Пример #6
0
        public void DoPivoitPrint(PivotGridControl pivotGridControl, bool landscape = true)
        {
            var link = new PrintableComponentLink(new PrintingSystem())
            {
                Margins = { Left = 10, Right = 10, Top = 110, Bottom = 90 },
                Landscape = landscape,
                PaperKind = PaperKind.A4,
                Component = pivotGridControl
            };

            var footer = new PageFooterArea();
            footer.Content.Add("Printed on " + "[Date Printed]" + " by " + Utils.Username);
            footer.Content.Add("Page " + "[Page #]");
            footer.LineAlignment = BrickAlignment.Near;
            var header = new PageHeaderArea();

            link.CreateMarginalHeaderArea += CreateMarginalDetailHeaderArea;
            link.CreateMarginalFooterArea += CreateMarginalFooterArea;

            link.PageHeaderFooter = new PageHeaderFooter(header, footer);

            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Save, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Watermark, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.FillBackground, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.HandTool, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Customize, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Scale, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Parameters, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SubmitParameters, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Background, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.None, CommandVisibility.None);
            link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.None);
            link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Document"].Visible =
                false;
            link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Background"].Visible =
                false;
            link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Zoom"].Visible =
                false;


            link.CreateDocument();

            link.PrintingSystem.Document.AutoFitToPagesWidth = 1;

            link.ShowRibbonPreview(UserLookAndFeel.Default);
        }