Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

printing in .net

2,001 views
Skip to first unread message

Josh Harris

unread,
Jan 19, 2004, 11:39:12 AM1/19/04
to
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";
proc.Start();


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.

Thanks

Evan Stone

unread,
Jan 22, 2004, 4:51:57 PM1/22/04
to
> 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,
however).
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.

Evan Stone

unread,
Jan 22, 2004, 5:01:38 PM1/22/04
to
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
> needed.

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!

;)

Jeff Callahan

unread,
Jan 22, 2004, 5:48:11 PM1/22/04
to
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...

jeff.

--

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
http://www.microsoft.com/info/cpyright.htm

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

Josh Harris

unread,
Jan 26, 2004, 1:12:14 PM1/26/04
to
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.
0 new messages