PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

Printing rendered documents and additional PDF's
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2020
Page 1 of 1

Author:  ghendric [ Mon May 14, 2012 5:25 pm ]
Post subject:  Printing rendered documents and additional PDF's

I'm not sure where to go with this as I am going by the document viewer sample. Basically, I need to print/print preview my rendered document plus add additional PDF files to the preview & print. What would be the best way to do this? Should I merge all my PDF's including the rendered document into one PDF file before printing or previewing them using PDFDocument/PDFPage or is there a way to merge pdf's into 1 document with MigraDocPrintDocument class? This is the code I have now for printing and previewing based on the sample provided.

Code:
        private void PrintPreview(object sender, ItemClickEventArgs e) {
            try {
                printPreviewDialog1.Text = "Print Preview";
                printPreviewDialog1.ClientSize = new System.Drawing.Size(700, 500);
                DocumentRenderer renderer = documentPreview1.Renderer;
                MigraDocPrintDocument printDocument = new MigraDocPrintDocument() { PrinterSettings = _printerSettings, Renderer = renderer };
                printPreviewDialog1.Document = printDocument;
                printPreviewDialog1.ShowDialog();
            } catch (Exception ex) {
                throw ex;
            }
        }
       
        private void PrintDocument(object sender, ItemClickEventArgs e) {
            try {
                DocumentRenderer renderer = documentPreview1.Renderer;
                if (renderer != null) {
                    using (MigraDocPrintDocument printDocument = new MigraDocPrintDocument()) {
                        printDocument.PrinterSettings = _printerSettings;
                        if (_printerSettings.PrintRange == PrintRange.Selection)
                            printDocument.SelectedPage = documentPreview1.Page;
                        printDocument.Renderer = renderer;
                        printDocument.Print();
                    }
                }
            } catch (Exception ex) {
                throw ex;
            }
        }       

Author:  Thomas Hoevel [ Tue May 15, 2012 9:53 am ]
Post subject:  Re: Printing rendered documents and additional PDF's

Hi!

You can add pages from PDF files to your MigraDoc document. These pages will not show on the Preview (I'm not sure if printing will work).
The pages will be included when you create a PDF file (IIRC they won't show in RTF files).

So when adding PDF pages, create a PDF file from MigraDoc.

Author:  ghendric [ Tue May 15, 2012 1:08 pm ]
Post subject:  Re: Printing rendered documents and additional PDF's

Do you have an example on how to do that?

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/