예제 #1
0
        /// <summary>
        /// This is the event handler for PrintDocument.AddPages. It provides all pages to be printed, in the form of
        /// UIElements, to an instance of PrintDocument. PrintDocument subsequently converts the UIElements
        /// into a pages that the Windows print system can deal with.
        /// </summary>
        /// <param name="sender">PrintDocument</param>
        /// <param name="e">Add page event arguments containing a print task options reference</param>
        protected virtual void AddPrintPages(object sender, AddPagesEventArgs e)
        {
            // Loop over all of the preview pages and add each one to  add each page to be printied
            for (int i = 0; i < printPreviewPages.Count; i++)
            {
                // We should have all pages ready at this point...
                printDocument.AddPage(printPreviewPages[i]);
            }

            PrintDocument printDoc = (PrintDocument)sender;

            // Indicate that all of the print pages have been provided
            printDoc.AddPagesComplete();
        }
        protected override void OnAddPrintPages(AddPagesEventArgs e)
        {
            IList <Windows.Graphics.Printing.PrintPageRange> customPageRanges = e.PrintTaskOptions.CustomPageRanges;
            int pageCount = this.PageDictionary.Count;

            // An empty CustomPageRanges means "All Pages"
            if (customPageRanges.Count == 0)
            {
                // Loop over all of the preview pages and add each one to be printed
                for (var i = 1; i <= pageCount; i++)
                {
                    var printpageControl = CreatePage(i);
                    PrintDocument.AddPage(printpageControl);
                }
            }
            else
            {
                // Print only the pages chosen by the user.
                //
                // The "Current page" option is a special case of "Custom set of pages".
                // In case the user selects the "Current page" option, the PrintDialog
                // will turn that into a CustomPageRanges containing the page that the user was looking at.
                // If the user typed in an indefinite range such as "6-", the LastPageNumber value
                // will be whatever this sample app last passed into the PrintDocument.SetPreviewPageCount API.
                foreach (PrintPageRange pageRange in customPageRanges)
                {
                    // The user may type in a page number that is not present in the document.
                    // In this case, we just ignore those pages, hence the checks
                    // (pageRange.FirstPageNumber <= printPreviewPages.Count) and (i <= printPreviewPages.Count).
                    //
                    // If the user types the same page multiple times, it will be printed multiple times
                    // (e.g 3-4;1;1 will print pages 3 and 4 followed by two copies of page 1)
                    if (pageRange.FirstPageNumber <= pageCount)
                    {
                        for (int i = pageRange.FirstPageNumber; (i <= pageRange.LastPageNumber) && (i <= pageCount); i++)
                        {
                            // Subtract 1 because page numbers are 1-based, but our list is 0-based.
                            var printpageControl = CreatePage(i);
                            PrintDocument.AddPage(printpageControl);
                        }
                    }
                }
            }
            // Indicate that all of the print pages have been provided.
            PrintDocument.AddPagesComplete();
        }
예제 #3
0
        /// <summary>
        /// This is the event handler for PrintDocument.AddPages. It provides all pages to be printed, in the form of
        /// UIElements, to an instance of PrintDocument. PrintDocument subsequently converts the UIElements
        /// into a pages that the Windows print system can deal with.
        /// </summary>
        /// <param name="sender">PrintDocument</param>
        /// <param name="e">Add page event arguments containing a print task options reference</param>
        protected virtual void AddPrintPages(object sender, AddPagesEventArgs e)
        {
            var paperSize = e.PrintTaskOptions.GetPageDescription(0).PageSize;

            System.Diagnostics.Debug.WriteLine("AddPrintPages: {" + paperSize.Width + "," + paperSize.Height + "}");

            // Loop over all of the preview pages and add each one to  add each page to be printied
            for (int i = 0; i < printPreviewPages.Count; i++)
            {
                // We should have all pages ready at this point...
                printDocument.AddPage(printPreviewPages[i]);
            }

            PrintDocument printDoc = (PrintDocument)sender;

            // Indicate that all of the print pages have been provided
            printDoc.AddPagesComplete();
        }
예제 #4
0
        void OnPrintDocumentAddPages(object sender, AddPagesEventArgs args)
        {
            if (customPageRange != null && customPageRange.IsValid)
            {
                foreach (int oneBasedIndex in customPageRange.PageMapping)
                {
                    printDocument.AddPage(bookPages[oneBasedIndex - 1]);
                }
            }
            else
            {
                foreach (UIElement bookPage in bookPages)
                {
                    printDocument.AddPage(bookPage);
                }
            }

            printDocument.AddPagesComplete();
        }
예제 #5
0
        /// <summary>
        /// This is the event handler for PrintDocument.AddPages. It provides all pages to be printed, in the form of
        /// UIElements, to an instance of PrintDocument. PrintDocument subsequently converts the UIElements
        /// into a pages that the Windows print system can deal with.
        /// </summary>
        /// <param name="sender">PrintDocument</param>
        /// <param name="e">Add page event arguments containing a print task options reference</param>
        private async void AddPrintPages(object sender, AddPagesEventArgs e)
        {
            // Loop over all of the pages and add each one to be printed
            pages.Clear();
            foreach (FrameworkElement page in c1PdfViewer1.GetPages())
            {
                pages.Add(page);
            }

            foreach (FrameworkElement page in pages)
            {
                printDocument.AddPage(page);
            }

            PrintDocument printDoc = (PrintDocument)sender;

            // Indicate that all of the print pages have been provided
            printDoc.AddPagesComplete();
        }
        /// <summary>
        /// This is the event handler for PrintDocument.AddPages. It provides all pages to be printed, in the form of
        /// UIElements, to an instance of PrintDocument. PrintDocument subsequently converts the UIElements
        /// into a pages that the Windows print system can deal with.
        /// </summary>
        /// <param name="sender">PrintDocument</param>
        /// <param name="e">Add page event arguments containing a print task options reference</param>
        protected override void AddPrintPages(object sender, AddPagesEventArgs e)
        {
            // Clear the cache of print pages
            printPages.Clear();

            // Clear the print canvas of print pages
            PrintCanvas.Children.Clear();

            // This variable keeps track of the last RichTextBlockOverflow element that was added to a page which will be printed
            RichTextBlockOverflow lastRTBOOnPage;

            // Get the PrintTaskOptions
            PrintTaskOptions printingOptions = ((PrintTaskOptions)e.PrintTaskOptions);

            // Get the page description to deterimine how big the page is
            PrintPageDescription pageDescription = printingOptions.GetPageDescription(0);

            // We know there is at least one page to be printed. passing null as the first parameter to
            // AddOnePrintPage tells the function to add the first page.
            lastRTBOOnPage = AddOnePrintPage(null, pageDescription);

            // We know there are more pages to be added as long as the last RichTextBoxOverflow added to a print
            // page has extra content
            while (lastRTBOOnPage.HasOverflowContent && (lastRTBOOnPage.Visibility == Windows.UI.Xaml.Visibility.Visible))
            {
                lastRTBOOnPage = AddOnePrintPage(lastRTBOOnPage, pageDescription);
            }

            // Loop over all of the pages and add each one to add each page to be printed
            for (int i = 0; i < printPages.Count; i++)
            {
                // We should have all pages ready at this point...
                printDocument.AddPage(printPages[i]);
            }

            PrintDocument printDoc = (PrintDocument)sender;

            // Indicate that all of the print pages have been provided
            printDoc.AddPagesComplete();
        }
        private void AddPages(object sender, AddPagesEventArgs e) //ДОБАВИТЬ СТРАНИЦЫ НА ПЕЧАТЬ
        {
            Pages = new List <UIElement>();
            Pages.Clear();

            MainPrintingText.Margin = new Thickness(10, 70, 0, 0);//возвращаем обратно

            Pages.Add(PanelPrePrint);

            for (int i = 0; i < Pages.Count; i++)
            {
                printDoc.AddPage(Pages[i]);
            }

            PrintDocument printDocument = (PrintDocument)sender;

            // Indicate that all of the print pages have been provided
            printDocument.AddPagesComplete();

            // Indicate that all of the print pages have been provided
            //printDoc.AddPagesComplete();
        }
 private void PrintDoc_AddPages(object sender, AddPagesEventArgs e)
 {
     printDoc.AddPage(ViewToPrint);
     printDoc.AddPagesComplete();
 }
예제 #9
0
 private void PrintDocument_AddPages(object sender, AddPagesEventArgs e)
 {
     Debug.WriteLine("PrintDocument_AddPages");
     printDocument.AddPage(printContent);
     printDocument.AddPagesComplete();
 }
예제 #10
0
 private void PrintDoc_AddPages(object sender, AddPagesEventArgs e)
 {
     printDoc.AddPage(rectangle);
     printDoc.AddPagesComplete();
 }
예제 #11
0
 private void PrintDic_AddPages(object sender, AddPagesEventArgs e)
 {
     printDoc.AddPage(this);
     printDoc.AddPagesComplete();
 }
예제 #12
0
 private void AddPages(object sender, AddPagesEventArgs e)
 {
     printDoc.AddPage(this.RectangleToPrint);
     // Indicate that all of the print pages have been provided
     printDoc.AddPagesComplete();
 }
예제 #13
0
 void OnPrintDocumentAddPages(object sender, AddPagesEventArgs args)
 {
     printDocument.AddPage(border);
     printDocument.AddPagesComplete();
 }
예제 #14
0
 private void PrintDoc_AddPages(object sender, AddPagesEventArgs e)
 {
     printDoc.AddPage(testPanel);
     printDoc.AddPagesComplete();
 }
예제 #15
0
        protected virtual void AddPrintPages(object sender, AddPagesEventArgs e)
        {
            PrintDoc.AddPage(PrintContent);

            PrintDoc.AddPagesComplete();
        }
예제 #16
0
 private void OnPrintDocumentAddPages(object sender, AddPagesEventArgs args)
 {
     _printDocument.AddPage(Page1);
     _printDocument.AddPage(Page2);
     _printDocument.AddPagesComplete();
 }
예제 #17
0
 private void _printDocument_AddPages(object sender, AddPagesEventArgs e)
 {
     _printDocument.AddPage(PrintGrid);
     _printDocument.AddPagesComplete();
 }