PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Jun 01, 2009 3:11 pm 
Offline

Joined: Fri Feb 20, 2009 11:19 pm
Posts: 10
Instead of creating an rtf or pdf and then printing I'm trying to work from the DocumentViewer example and create and print a MigraDoc PrintDocument and print from there. I'm working in a browser in evironment not windows forms. Any help at at all would be great.

I keep running into the error
Object reference not set to an instance of an object.
Line 1685: printDocument.Print();


// Reuse the renderer from the preview
ddl = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document1);

DocumentRenderer renderer = new DocumentRenderer(document1);
if (renderer != null)
{
//int pageCount = renderer.FormattedDocument.PageCount;

// Creates a PrintDocument that simplyfies printing of MigraDoc documents
MigraDocPrintDocument printDocument = new MigraDocPrintDocument();
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.PrintRange = PrintRange.AllPages;

// Attach the current printer settings

// Attach the current document renderer
printDocument.Renderer = renderer;

// Print the document
printDocument.Print();
}


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 29, 2009 3:54 pm 
Offline

Joined: Thu Oct 29, 2009 2:48 pm
Posts: 1
You need to call renderer.PrepareDocument() after you create the renderer.

Code:
...
DocumentRenderer renderer = new DocumentRenderer(document1);
if (renderer != null)
{
    renderer.PrepareDocument();
...


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 383 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