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

Free Support Forum - aspose.com

Synchronous Printing

Hi,


Just a quick question - if I print using a Aspose.Words.Document, is this synchronous? (or is there a way to make this synchronous?).

i.e. If I have a collection of documents to print, and print them one by one and in order, is there any way to guarantee that they get printed by the printer in the order that I printed them in code?

Thanks,
-Sam

Hi Sam,


Thanks for your inquiry. All methods (including the Print method) in Aspose.Words library are synchronous i.e. when a method returns, the operation would have been completed. On the other hand, if the method cannot complete an operation, it simply throws an exception.

The Aspose.Words.Document object provides a family of the Print methods to print documents and these methods print via the .NET printing classes defined in the System.Drawing.Printing namespace. There are many customers of Aspose.Words who use these printing methods in their applications (including server side) without any problems. But it came to our attention that Microsoft recommends against using the System.Drawing.Printing classes within a Windows service or ASP.NET application or service. See http://msdn.microsoft.com/en-us/library/system.drawing.printing.aspx for more info.

The way to print documents suggested by Microsoft is to use the XpsPrint API http://msdn.microsoft.com/en-us/library/dd374565(VS.85).aspx. This API is available on Windows 7, Windows Server 2008 R2 and also Windows Vista, provided the Platform Update for Windows Vista is installed. Since Aspose.Words can easily convert any document into XPS, you can use the “XpsPrint” example project to print a document via the XpsPrint API. You can find “XpsPrint” project in Aspose.Words for .NET examples repository at GitHub.

Please notice the following method in “XpsPrintHelper.cs” class:

public static void Print(Aspose.Words.Document document, string printerName, string jobName, bool isWait)
isWait parameter: True to wait for the job to complete. False to return immediately after submitting the job.

I hope, this helps.

Best regards,