4

(Short version at the end)

The software I'm currently developing is required to track an arbitrary number of MS Office files, and now needs to provide the functionality to print all of those files together, along with some application data (likely to be sent to the printer as a file of type .xps, .html, or .txt). Printing each file one by one is fairly trivial, but results in separate print jobs for each of them. This is very bad in the case of printers set up in an office to print a sheet at the beginning of each print job with the username and time of the print job, and it could allow other users sharing the printer to print between the jobs. Additionally, would there be the possibility that the jobs are not processed in the proper order?1

Is there any way to combine an arbitrary collection of Office documents as a single print job?

EDIT: An alternative solution that would be acceptable is a way to combine all of the documents to a single pdf/xps (or similar) document? This would both accomplish the primary goal, and enable quicker printing of future copies, as we could print that one large document instead of each individual document (until, of course, a new document is added).

1(Edited in after original post)

Short Version

Given:

  • Arbitrary collection of MS Office files (.doc[x], .xls[x], .ppt[x])
  • Application data (string is generated, can be printed to .txt, .html, etc)

Acheive:

  • Print all files as a single print job, either by combining to one job, or combining to one file before print.

Question:
Can it be done? If so, how?

yoozer8
  • 7,361
  • 7
  • 58
  • 93
  • have you seen http://stackoverflow.com/questions/5320990/appending-an-xps-document-to-an-existing-one ? – jcolebrand Oct 13 '11 at 18:34
  • 1
    take a look at http://msdn.microsoft.com/en-us/library/bb448854.aspx – Security Hound Oct 13 '11 at 18:43
  • 1
    Also take a look at http://stackoverflow.com/questions/3444931/how-to-merge-two-postscript-files-together . You should use the GPL version and follow its license; the AFPL version is licensed in a way that would prevent you from distributing it with your applications at all (assuming they're commercial applications). You would need the GPL code to be kept as a separate application called by your program to avoid licensing issues. Of course, you should verify rather than trust legal advice from a random SO user; I might be wrong. – Brian Oct 13 '11 at 19:37
  • Is the software you develop server-side (like Windows Service, IIS/ASP.NET etc.) ? – Yahia Oct 13 '11 at 19:48

1 Answers1

1

Yes - if you convert all content into PDFs and join those PDFs into one...

There are some libraries out there to achieve this - but if you want to cover all office formats you might need to consider Aspose.Total .NET (not affiliated, just a happy customer)...

EDIT - as per comments:

Another option (esp. since the software is essentially a "desktop app" and http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2 does not apply mostly) is to use Office Interop to create PDF files. Text can be converted to PDF rather easily (for example by using Office Interop/Word and creating an intermediary Word document with that text).

Altogether this allows for most of the functionality asked... to make sure that no other print jobs com inbetween one could merge the PDF files into one PDF and print that... for merging PDFs there are several libraries (free like Ghostscript, commercial like Gnostice PDFOne) out there - some even allow the creation of PDFs from text/images avoiding the intermediary Word document mentioned above).

Yahia
  • 69,653
  • 9
  • 115
  • 144
  • It's been considered, but turned down due to licensing costs. – yoozer8 Oct 13 '11 at 19:35
  • Although if there is a free (or significantly cheaper) tool to combine PDFs, we could use the Office Interop functionality to save each file as a PDF and then merge them to create the document - this only leaves out the application's data. – yoozer8 Oct 13 '11 at 19:36
  • I searched a long for a library supported all Office formats (old xls and current xlsx and ppt/pptx etc.) and never found anything nearly as complete as Aspose... – Yahia Oct 13 '11 at 19:37
  • @Jim Is the software you develop server-side (like Windows Service, IIS/ASP.NET etc.) ? – Yahia Oct 13 '11 at 19:41
  • A server-side use of Office-Interop is not supported by MS - see http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2 – Yahia Oct 13 '11 at 20:08
  • Yes, I'm aware of that. However, since the server IS the client (I'm surprised this was developed as a web application rather than a desktop), a lot of those issues can be avoided. – yoozer8 Oct 13 '11 at 20:10
  • what do you mean by "the server IS the client" technically ? – Yahia Oct 13 '11 at 20:11
  • ok - then the technical side is covered, the only problem remaining is the licensing issues when using MS OFfice this way... – Yahia Oct 13 '11 at 20:15