示例#1
0
        static public bool Print(IPrintableImage image)
        {
            currentImage = image;

            if (PrintSettings != null)
            {
                printOperationAction = PrintOperationAction.Print;
            }
            else
            {
                PrintSettings = new PrintSettings();
            }

            printOperation.PrintSettings = PrintSettings;
            PrintSettings.NCopies        = currentImage.CopiesToPrint;

            if (currentImage.Orientation == DocumentOrientation.Landscape)
            {
                printOperation.RequestPageSetup += PrintOperation_RequestPageSetup;
            }

            PrintSettings.Orientation = currentImage.Orientation == DocumentOrientation.Portrait ? PageOrientation.Portrait : PageOrientation.Landscape;

            printOperation.Run(printOperationAction, null);
            status = printOperation.Status;
            //если отмена из диалога печати
            if (status.HasValue && status.Value == PrintStatus.FinishedAborted)
            {
                PrintingCanceled?.Invoke(printOperation, new EventArgs());
                return(false);
            }

            PrintSettings = printOperation.PrintSettings;
            return(true);
        }
示例#2
0
        public Report(string reportName, string svgFile)
        {
            // Load svg file
            this.svgDocument = new SvgDocument(svgFile);

            // Create PrintOperation object
            this.printOperation                = new PrintOperation();
            this.printOperation.NPages         = 1;
            this.printOperation.Unit           = Unit.Mm;
            this.printOperation.JobName        = reportName;
            this.printOperation.ExportFilename = "test.pdf";

            PrintSettings psettings = new PrintSettings();
            PaperSize     paperSize = new PaperSize("customPaperSize", "cps",
                                                    this.svgDocument.PageWidth,
                                                    this.svgDocument.PageHeight,
                                                    Unit.Mm);

            psettings.PaperSize = paperSize;

            Console.WriteLine("PageHeight: " + this.svgDocument.PageHeight.ToString());
            Console.WriteLine("PageWidth: " + this.svgDocument.PageWidth.ToString());
            Console.WriteLine();
            this.printOperation.PrintSettings = psettings;

            printOperation.DrawPage   += this.DrawPage;
            printOperation.BeginPrint += this.BeginPrint;

            // Set default action
            this.action = PrintOperationAction.Export;

            // Data
            this.data       = new Dictionary <string, string>();
            this.dataTables = new Dictionary <string, DataTable>();

            this.pageHeader = this.svgDocument.PageHeaderSection;
            this.pageDetail = this.svgDocument.PageDetailSection;
            this.pageFooter = this.svgDocument.PageFooterSection;
        }
示例#3
0
        public Report(string reportName, string svgFile)
        {
            // Load svg file
            this.svgDocument = new SvgDocument(svgFile);

            // Create PrintOperation object
            this.printOperation = new PrintOperation();
            this.printOperation.NPages = 1;
            this.printOperation.Unit = Unit.Mm;
            this.printOperation.JobName = reportName;
            this.printOperation.ExportFilename = "test.pdf";

            PrintSettings psettings = new PrintSettings();
            PaperSize paperSize = new PaperSize("customPaperSize", "cps",
                                                this.svgDocument.PageWidth,
                                                this.svgDocument.PageHeight,
                                                Unit.Mm);
            psettings.PaperSize = paperSize;

            Console.WriteLine("PageHeight: " + this.svgDocument.PageHeight.ToString());
            Console.WriteLine("PageWidth: " + this.svgDocument.PageWidth.ToString());
            Console.WriteLine();
            this.printOperation.PrintSettings = psettings;

            printOperation.DrawPage += this.DrawPage;
            printOperation.BeginPrint += this.BeginPrint;

            // Set default action
            this.action = PrintOperationAction.Export;

            // Data
            this.data = new Dictionary<string, string>();
            this.dataTables = new Dictionary<string, DataTable>();

            this.pageHeader = this.svgDocument.PageHeaderSection;
            this.pageDetail = this.svgDocument.PageDetailSection;
            this.pageFooter = this.svgDocument.PageFooterSection;
        }
示例#4
0
		void RunPrintOperation (PrintOperationAction action, PrintingSettings settings)
		{
			var op = new SourceEditorPrintOperation (TextEditor.Document, Name);
			
			if (settings.PrintSettings != null)
				op.PrintSettings = settings.PrintSettings;
			if (settings.PageSetup != null)
				op.DefaultPageSetup = settings.PageSetup;
			
			//FIXME: implement in-place preview
			//op.Preview += HandleOpPreview;
			
			//FIXME: implement async on platforms that support it
			var result = op.Run (action, IdeApp.Workbench.RootWindow);
			
			if (result == PrintOperationResult.Apply)
				settings.PrintSettings = op.PrintSettings;
			else if (result == PrintOperationResult.Error)
				//FIXME: can't show more details, GTK# GetError binding is bad
				MessageService.ShowError (GettextCatalog.GetString ("Print operation failed."));
		}
示例#5
0
        /// <summary>
        /// Альтернативная релализация печати, специально для обхода бага в кайро при поворачивании(со старой реализацией печати пол Linux)
        /// https://bugzilla.mozilla.org/show_bug.cgi?id=1205854#c16
        /// В новой при установке ориентации для каждой странице на большенстве принтеров обрезается часть выходящая за поворот. Хотя ориентация правильная.
        /// На некоторых принтерах например в водовозе, табличка рисуется за вертикалью листа а текст нет.
        /// используется только на винде, в линуксе такой проблемы нет.
        /// </summary>
        private PrintSettings PrintAll_Win_Workaround(IEnumerable <IPrintableDocument> documents)
        {
            PrintOperation printOp       = null;
            PrintSettings  printSettings = null;

            var documentsRDL_Portrait  = documents.Where(doc => doc.PrintType == PrinterType.RDL && doc.Orientation == DocumentOrientation.Portrait).ToList();
            var documentsRDL_Landscape = documents.Where(doc => doc.PrintType == PrinterType.RDL && doc.Orientation == DocumentOrientation.Landscape).ToList();

            if (!documents.Any())
            {
                printOp = new PrintOperation();
                printOp.Run(PrintOperationAction.PrintDialog, null);
                return(printOp.PrintSettings);
            }

            if (documentsRDL_Portrait.Any())
            {
                printOp                              = new PrintOperation();
                printOp.Unit                         = Unit.Points;
                printOp.UseFullPage                  = true;
                printOp.ShowProgress                 = true;
                printOp.DefaultPageSetup             = new PageSetup();
                printOp.DefaultPageSetup.Orientation = PageOrientation.Portrait;

                BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL_Portrait);

                var result = LongOperationDlg.StartOperation(
                    renderer.PrepareDocuments,
                    "Подготовка к печати портретных страниц...",
                    documentsRDL_Portrait.Count()
                    );
                if (result == LongOperationResult.Canceled)
                {
                    return(new PrintSettings());
                }

                printOp.NPages = renderer.PageCount;

                printOp.DrawPage += renderer.DrawPage;
                printOp.EndPrint += (o, args) => {
                    args.Args = documentsRDL_Portrait.Concat(documentsRDL_Landscape).ToArray();
                    DocumentsPrinted?.Invoke(o, args);
                };
                printOp.Run(PrintOperationAction.PrintDialog, null);
                printSettings = printOp.PrintSettings;
            }

            if (documentsRDL_Landscape.Any())
            {
                printOp                  = new PrintOperation();
                printOp.Unit             = Unit.Points;
                printOp.UseFullPage      = true;
                printOp.ShowProgress     = true;
                printOp.DefaultPageSetup = new PageSetup();

                //если printSettings == null, то значит, до этого не печатались RDL формата
                //PageOrientation.Portrait и, соответственно, не показывался PrintDialog и
                //нужно показать его сейчас.
                PrintOperationAction printOperationAction = PrintOperationAction.PrintDialog;
                if (printSettings != null)
                {
                    printOp.PrintSettings             = printSettings;
                    printOp.PrintSettings.Orientation = PageOrientation.Landscape;
                    printOperationAction = PrintOperationAction.Print;
                }
                printOp.DefaultPageSetup.Orientation = PageOrientation.Landscape;

                BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL_Landscape);

                var result = LongOperationDlg.StartOperation(
                    renderer.PrepareDocuments,
                    "Подготовка к печати альбомных страниц...",
                    documentsRDL_Landscape.Count()
                    );
                if (result == LongOperationResult.Canceled)
                {
                    return(new PrintSettings());
                }

                printOp.NPages    = renderer.PageCount;
                printOp.DrawPage += renderer.DrawPage;
                printOp.EndPrint += (o, args) => {
                    args.Args = documentsRDL_Portrait.Concat(documentsRDL_Landscape).ToArray();
                    DocumentsPrinted?.Invoke(o, args);
                };
                printOp.Run(printOperationAction, null);
            }
            return(printOp.PrintSettings);
        }