By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,949 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,949 IT Pros & Developers. It's quick & easy.

printing in .net

P: n/a
I have been searching newsgroups for solid answers on good printing
practices in .net, and have not found an answer. Obviously, .net
provides the PrintDocument/PrinterSettings objects, that from the
examples are great for printing lines with the graphics object. But
this is not very useful- how do I print a real document, like a word
doc, or a pdf? So far I have resorted to code such as the following
to print, but this does not give me the best control over my printing:

System.Diagnostics.Process proc = new Process();
proc.StartInfo.FileName = "ACROBAT.pdf";
proc.StartInfo.WorkingDirectory = "C:\\";
proc.StartInfo.Verb = "print";
I would like to use the PrintDocument and other printing object, but I
would love to see a good example of their use in the real world.

Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
> how do I print a real document, like a word
doc, or a pdf?

If you want to print those types of documents, I would imagine that you
would either have to:

a) Use OLE/COM Automation to "control" Word or Acrobat Reader to open and
print the document (not sure if Acrobat Reader is an OLE Automation server,
b) Build your own reader/renderer/printer for those documents, which isn't
really practical.

But there's another way, which brings up an interesting topic... DDE!

Through DDE*, you might be able to accomplish what you're looking for. I'm
not sure what commands Acrobat Reader supports, but it might be possible. I
know for sure Word supports it.

The one thing I don't know is if .NET has a library of classes/methods for
using DDE. Sounds like a good research project, however. I wouldn't be
surprised if there was support in the Framework, since the Windows File
Types dialog (and associated dialogs) allow you to set up relationships
based on DDE commands.

Hope this helps!

Evan Stone | Petaluma, CA
C#/.NET Padawan Learner

* DDE = Dynamic Data Exchange. Sorta like a poor man's OLE, going back to
the 16-bit days. But it was actually a pretty cool way of communicating
between applications, and is still alive today.

Nov 15 '05 #2

P: n/a
Looks bad, sports fans.

I just found the following in the .NET help system:
DDE Is Gone
Dynamic Data Exchange (DDE) is no longer available
as a technology in the .NET language. There are so
many other methods of communicating from one
program to another that this technology is no longer

So, bummer. Looks like you're stuck using OLE/COM Automation, which isn't a
bad thing. You'll just have to find out 1) if Acrobat supports Automation,
and 2) what object library you have to reference. After that it should be
fairly straightforward.

In fact, looking in my reference list (on the COM tab), I see three items
that look interesting:

* Acrobat Access 2.0 Type Library
* Acrobat Control for ActiveX
* AcroIEHelper 1.0 Type Library

So it looks like Adobe was a good COM citizen and created the tools
necessary to do what you want. I'd check out the first one and see how that
goes. There's probably some information on the Adobe site about it too.

Hope this helps more than the last message!


Evan Stone | Petaluma, CA
C#/.NET Padawan Learner
Nov 15 '05 #3

P: n/a
the problem is that word and pdf documents have very specific formatting
instructions and you would have to know exactly how to "draw" such a
document with respect to the formatting instructions if you'd like to print
using the .net classes. the printing classes work best when you have your
own document style which you understand and can therefore instruct the
framework how to render your formatting to a graphics object.

otherwise, the best you can do is hand a document to windows and hope it
can find the (installed) software that does know how to render the document
to the printer. is this what you were hoping to do?

let me know if you have more questions or if i didn't answer what you're
looking for...



This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they

Nov 15 '05 #4

P: n/a
Thanks for the replies. It looks as though my original post may well
be the best generic print methodology. I was trying to stay away from
ole automation for the purpose of creating a generic print method.
Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.