PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 12:04 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Oct 13, 2009 8:31 am 
Offline

Joined: Tue Oct 13, 2009 8:25 am
Posts: 2
Hi,

seems I am a little bit tired today, but I didn't get the right think to print some invoices :(
I use the sample to create some invoices and that works fine:
Code:
      InvoiceForm IF = new InvoiceForm();
      IF.Ort = dgv_Kunden.Rows[dgv_Kunden.CurrentRow.Index].Cells["Ort"].Value.ToString();
      IF.Positionen = dtRechnungsPositionen;
      doc = IF.CreateDocument();
      PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

      // Set the MigraDoc document
      pdfRenderer.Document = doc;

      // Create the PDF document
      pdfRenderer.RenderDocument();

      // Save the PDF document...
      string filename = Rechnungsnummer + ".pdf";
      pdfRenderer.Save(filename);
      // ...and start a viewer.
      Process.Start(filename);
      Gesamtsumme = IF.totalExtendedPrice;
      return filename;


But now I try to print these file only after creating, but I got the error that doc == null:(
tried it this way (and some other that didn't work:
Code:
      InvoiceForm IF = new InvoiceForm();
      IF.Positionen = dtRechnungsPositionen;
      doc = IF.CreateDocument();
      // Create a new MigraDoc document
     
      DocumentRenderer renderer = new DocumentRenderer(doc.Document);
      if (renderer != null)
      {
       
        MigraDocPrintDocument printDocument = new MigraDocPrintDocument();
        printDocument.Renderer = renderer;
        // Print the document
        printDocument.Print();
      }   



Can I get any hint whats wrong in my way to try it?

Best Regartds
Manfred


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 13, 2009 10:06 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!

Maybe you just have to call
Code:
renderer.PrepareDocument();

before
Code:
MigraDocPrintDocument printDocument = new MigraDocPrintDocument();

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 13, 2009 10:09 am 
Offline

Joined: Tue Oct 13, 2009 8:25 am
Posts: 2
Hi Thomas,

if doinig that, I got a NullReferneceException.

Any other idea?

[EDIT]
Copied that to the wrong place, put it to the right place and now it works. Thanks!
[/EDIT]
Best Regards
Manfred


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 432 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