We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception trying to print a word document

I’m getting an exception try to print a Word document. (See the exception and code below.)

So I have a couple questions.

Does the printing functionality really work in Aspose.Words? I’ve tried search the site for information on this and I’m getting fixed info. Is this feature still in beta? If yes, when will it be released?

If printing is not available, can I convert the word doc to a PDF and print the PDF using Aspose.Pdf? Is there another alternative to using Word to print the document?

If printing is available, is there any sample code for this on the web site. Again I searched the site but I didn’t find anything.

Here is the code I’m using.

Aspose.Words.Document doc = new Document(@"C:\Temp\Worksheet1.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
Bookmarks bookmarks = doc.Range.Bookmarks;
for (int i = 0; i < bookmarks.Count; i++)
{
    Bookmark bookmark = bookmarks;
    bookmark.Text = "TESTING!";
}
builder.MoveToBookmark("UserText3");
builder.Write("This is a test for Aspose.Words!!!");

DocumentRenderer renderer = new DocumentRenderer(doc);
renderer.Print();

doc.Save(@"C:\Temp\Worksheet1.doc");

The exception I receive is:

System.StackOverflowException was unhandled
An unhandled exception of type ‘System.StackOverflowException’ occurred in mscorlib.dll

I’m using version 3.6.1.0 of Aspose.Words for .Net. I downloaded this a few days ago to evaluate your product. So far the evaluation is going well but we require a solution that can print Word or PDF documents.

Thanks,
Scott

The latest official information about Aspose.Words.Viewer can be found here.

The printing capability will be out this year, but I cannot provide exact timeline yet. We are putting major effort in it and will try to release it as soon as possible.

Best regards,

We are happy to tell you that the new Rendering Engine has replaced the “old Viewer Beta”. The Rendering Engine can print, save as images or draw onto .NET Graphics object any document page.

Please see Aspose.Words documentation to learn more about new features.

Saving to image

In additional, new Rendering engine allows you to convert Word document to PDF directly (without using Aspose.Pdf).

Saving to Pdf

The latest version of Aspose.Words is available for download from downloads section or from NuGet