PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Wed Dec 03, 2025 5:37 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon May 14, 2012 5:25 pm 
Offline
User avatar

Joined: Sun Apr 22, 2012 3:47 pm
Posts: 26
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;
            }
        }       

_________________
Thanks,
George


Top
 Profile  
Reply with quote  
PostPosted: Tue May 15, 2012 9:53 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3139
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue May 15, 2012 1:08 pm 
Offline
User avatar

Joined: Sun Apr 22, 2012 3:47 pm
Posts: 26
Do you have an example on how to do that?

_________________
Thanks,
George


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 176 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group