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