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

Free Support Forum - aspose.com

How do I print several documents in one print job?


Our application prints several word-documents automatically when requested by the user. Each of these documents can have a different PaperSource, a different Number of Copies and a different value for Duplex. Each of these documents are created from different word-templates and different formattings. The printer is the same for all documents.

var _name = "Deskjet 740c";
foreach (var document in documents)
    var AsposeWordDocument = new Aspose.Words.Document(document.FullFilePath);
    using (var printDocument = new WordPrintDocument(AsposeWordDocument, document.PrinterPaperSource))
        printDocument.DocumentName = document.DocumentName;
        printDocument.PrinterSettings.PrinterName = _name;
        printDocument.PrinterSettings.Copies = document.NrCopies;
        printDocument.PrinterSettings.Duplex = document.IsDuplex ? Duplex.Horizontal : Duplex.Simplex;

The code above generates a print job for each document (each document appears separately in the printer queue).

How can I print all the documents in one job without using XPS?


P.S: The aim is that the documents of a single user are not mixed up with the documents from other users.

Hi there,

Thanks for your inquiry.

After some invesigation it seems the main recommendation for achievieng this in .NET is to join all documents together and send the combined document as one print job.

You can achieve this in Aspose.Words while preserving all properties and formatting for different documents e.g paper tray, section formatting, font, paragraph formatting are all preserved after this operation. However I’m not sure how this will tie in with your “Copies” and “Duplex” options above. If this isn’t suitable, could you please clarify further?

Document baseDoc = null;
foreach (Document doc in documents)
    if (baseDoc == null)
        baseDoc = doc;
        baseDoc.AppendDocument(doc, ImportFormatMode.KeepSourceFormatting);



Thanks for your reply. The problem is, as you’ve already pointed out, that it seems impossible to specify PaperSource, Copies and Duplex per Document now (as all Document are contained in baseDoc now). The requirement is that the PaperSource, Copies and Duplex can be configured per Document but printed-out in one printjob.

I could overwrite OnQueryPageSettings on den PrintDocument and do something like:

protected override void OnQueryPageSettings(QueryPageSettingsEventArgs e)
    e.PageSettings.PrinterSettings.Duplex = Duplex.Vertical;

but the problem is that I can’t find out from which document the currently printed page originates (in order to decide if it’s duplex or not) and I guess that’s not possible to change the PrinterSettings on a ‘per-page’ level anyway.

Do you see a way how to implement the requirement?
Would XPS solve my problem?

Thank you very much

Hi Jorg,

Thanks for your inquiry and my apologises for the late reply.

I suppose such attributes like Copies and Duplex is always per PrintJob and not per document (in .NET at least). Therefore it’s simply not possible to specify them separately for each document in the print job.

Have you tried your code example changing the settings per page on a real printer? Did it work?

I would highly suggest trying to use XPSPrint API. This format contains it’s own print settings per document and you may be able to achieve what you are looking for using this format.

If we can help with anything else, please feel free to ask.