Exemplo n.º 1
0
        private PreviewPageInfo[] CreatePreviewPageInfo()
        {
            //Console.WriteLine("Begin CreatePreviewPageInfo");

            // use not the print document directly, but a clone - since we evaluate the print preview in a separate task
            var printDocument = GetCloneOfPrintDocument(Current.PrintingService.PrintDocument);

            var printTask = new GraphDocumentPrintTask(_doc)
            {
                IsPrintPreview = true
            };
            var _previewController = new System.Drawing.Printing.PreviewPrintController();

            printDocument.PrintController    = _previewController;
            printDocument.PrintPage         += printTask.EhPrintPage;
            printDocument.QueryPageSettings += printTask.EhQueryPageSettings;

            printDocument.Print();

            printDocument.PrintPage         -= printTask.EhPrintPage;
            printDocument.QueryPageSettings -= printTask.EhQueryPageSettings;
            printDocument.PrintController    = null;

            //Console.WriteLine("End CreatePreviewPageInfo");
            return(_previewController.GetPreviewPageInfo());
        }
Exemplo n.º 2
0
		public PrintPreviewControl() {
			autozoom = true;
			columns = 1;
			rows = 0;
			startPage = 1;

			this.BackColor = SystemColors.AppWorkspace;

			controller = new PreviewPrintController ();

			vbar = new ImplicitVScrollBar ();
			hbar = new ImplicitHScrollBar ();

			vbar.Visible = false;
			hbar.Visible = false;
			vbar.ValueChanged += new EventHandler (VScrollBarValueChanged);
			hbar.ValueChanged += new EventHandler (HScrollBarValueChanged);

			SuspendLayout ();
			Controls.AddImplicit (vbar);
			Controls.AddImplicit (hbar);
			ResumeLayout ();
		}
        private void GeneratePreview()
        {
            m_currentPreviewPage = null;

              PrintDocument document = this.PrintDocument;

              if( document == null )
            return;

              PrintController oldController = document.PrintController;

              try
              {
            Cursor.Current = Cursors.WaitCursor;

            PreviewPrintController controller = new PreviewPrintController();

            document.PrintController = controller;
            document.PrintPage += new PrintPageEventHandler( document_PrintPage );
            document.Print();
            document.PrintPage -= new PrintPageEventHandler( document_PrintPage );

            PreviewPageInfo[] pages = controller.GetPreviewPageInfo();

            m_currentPreviewPage = pages[ 0 ];
              }
              finally
              {
            document.PrintController = oldController;
            Cursor.Current = Cursors.Default;
              }
        }
Exemplo n.º 4
0
 private void ComputePreview()
 {
     int startPage = this.StartPage;
     if (this._document == null)
     {
         this._pageInfo = new PreviewPageInfo[0];
     }
     else
     {
         PrintController printController = this._document.PrintController;
         PreviewPrintController underlyingController = new PreviewPrintController();
         underlyingController.UseAntiAlias = this.UseAntiAlias;
         PrintController controller3 = new PrintPreviewDialog.PrintPreviewUIPrintController(underlyingController, (PrintPreviewDialog) base.Parent);
         try
         {
             this._document.PrintController = controller3;
             this._document.Print();
             this._pageInfo = underlyingController.GetPreviewPageInfo();
         }
         finally
         {
             this._document.PrintController = printController;
         }
     }
     if (startPage != this.StartPage)
     {
         this.OnStartPageChanged(EventArgs.Empty);
     }
 }
Exemplo n.º 5
0
        // "Prints" the document to memory
        private void ComputePreview() {
            int oldStart = StartPage;

            if (document == null)
                pageInfo = new PreviewPageInfo[0];
            else {
                IntSecurity.SafePrinting.Demand(); 

                PrintController oldController = document.PrintController;
                PreviewPrintController previewController = new PreviewPrintController();
                previewController.UseAntiAlias = UseAntiAlias;
                document.PrintController = new PrintControllerWithStatusDialog(previewController, 
                                                                               SR.GetString(SR.PrintControllerWithStatusDialog_DialogTitlePreview));

                // Want to make sure we've reverted any security asserts before we call Print -- that calls into user code
                document.Print();
                pageInfo = previewController.GetPreviewPageInfo();
                Debug.Assert(pageInfo != null, "ReviewPrintController did not give us preview info");

                document.PrintController = oldController;
            }

            if (oldStart != StartPage) {
                OnStartPageChanged(EventArgs.Empty);
            }
        }
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// PDF print document constructor
        /// </summary>
        /// <param name="Document">Current PDF document</param>
        /// <param name="Resolution">Image resolution</param>
        ////////////////////////////////////////////////////////////////////
        public PdfPrintDocument(
			PdfDocument Document,
			Double		Resolution			// printer resolution in pixels per inch
			)
        {
            // save document
            this.Document = Document;

            // save resolution
            this.Resolution = Resolution;

            // create print document and preview controller objects
            PrintController = new PreviewPrintController();

            // copy document's page size to default settings
            // convert page size from points to 100th of inch
            // do not set lanscape flag
            PaperSize PSize = new PaperSize();
            PSize.Width = (Int32) (Document.PageSize.Width / 0.72 + 0.5);
            PSize.Height = (Int32) (Document.PageSize.Height / 0.72 + 0.5);
            DefaultPageSettings.PaperSize = PSize;

            // assume document is in color
            DefaultPageSettings.Color = true;
            return;
        }
Exemplo n.º 7
0
        private void drawPreviewPage()
        {
            if (rezimRada == RezimRada.MyPreviewDraw)
            {
                izvestaj.TimeOfPrint = DateTime.Now;
                bitmapGraphics.Clear(Color.White);
                drawPage(bitmapGraphics, previewPage);
                pictureBox1.Image = bitmap;
                return;
            }
            else if (rezimRada == RezimRada.PageSizeTooSmall)
            {
                bitmapGraphics.Clear(Color.White);
                pictureBox1.Image = bitmap;
                return;
            }

            PrintController oldControler = printDocument1.PrintController;
            PreviewPrintController prevControler = new PreviewPrintController();
            printDocument1.PrintController = prevControler;
            page = previewPage;
            lastPageToPrint = previewPage;
            printDocument1.Print();
            printDocument1.PrintController = oldControler;

            PreviewPageInfo pageInfo = prevControler.GetPreviewPageInfo()[0];
            // PhysicalSize is in 0.01 inch
            pictureBox1.ClientSize = pageToScreen(new SizeF(
                pageInfo.PhysicalSize.Width / 100f,
                pageInfo.PhysicalSize.Height / 100f));
            pictureBox1.Image = pageInfo.Image; // Metafile
        }
 private void ComputePreview()
 {
     int startPage = this.StartPage;
     if (this.document == null)
     {
         this.pageInfo = new PreviewPageInfo[0];
     }
     else
     {
         System.Windows.Forms.IntSecurity.SafePrinting.Demand();
         PrintController printController = this.document.PrintController;
         PreviewPrintController underlyingController = new PreviewPrintController {
             UseAntiAlias = this.UseAntiAlias
         };
         this.document.PrintController = new PrintControllerWithStatusDialog(underlyingController, System.Windows.Forms.SR.GetString("PrintControllerWithStatusDialog_DialogTitlePreview"));
         this.document.Print();
         this.pageInfo = underlyingController.GetPreviewPageInfo();
         this.document.PrintController = printController;
     }
     if (startPage != this.StartPage)
     {
         this.OnStartPageChanged(EventArgs.Empty);
     }
 }