Yet another printing question

Hi there everyone....
I have done tons of reading in this forum and others about the best way to print documents (word and pdf) and have mixed reviews. If anyone can answer my question I will be eternally grateful... here goes...

in .Net's PrintDocument class, how do I print a word document using this class I have read that you need to stream text to the class, but if I open a streamreader of the word file, will it lose the formatting

I know I can use interop to do this printing, but all documentation I have read indicates I shouldn't do this, and besides I don't get the printer control I need when doing this.

any ideas or suggesstions will be helpful..

Thanks

Justin


Answer this question

Yet another printing question

  • BaluMunugoti

    Nobody got any suggesstions for me I've got clumps of hair round my chair!!

  • fafnir

    Basically, you don't use the PrintDocument class to, ahem, print documents.

    If you want to print a Word Document, you will have to either use the Word Interop library(ies), or start a process which activates Word with the correct parameters to print a document. Streaming the underlying bytes of the document are going to do you no good unless you are familiar with the word format, and can interpret that format, and present/display that format.

    You could just abandon Word altogether, if it's a simple document, and just use text or rich text (or HTML, or XML) and handle everything in your application. Alternatively, if the document is complex or pre-existing, write whatever it is you want to do in the Word scripting evironment (VBA), and not use a separate (VB) application: it all depends on your workflow process, and what you are trying to achieve.



  • ToddOs

    thanks Stephen. I have decided to use the interop and automate the word object to print. Thanks for your comments.

  • Gavin Lilley

    Hi Justin,

    How did you eventually use the interop to automate the word object and print the Word Document I have the very same problem that you were having where the Word document is printed but all formatting and images are lost. I am using the PrintDocument because I am able to manipulate the printer/tray settings.


  • Yet another printing question