473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

printing in .net

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
Nov 15 '05 #1
4 1381
> 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.

Nov 15 '05 #2
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!

;)

Evan Stone | Petaluma, CA
----------------------------------------------
C#/.NET Padawan Learner
Nov 15 '05 #3
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.

Nov 15 '05 #4
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jody Gelowitz | last post by:
I am having a problem with printing selected pages. Actually, the problem isn't with printing selected pages as it is more to do with having blank pages print for those pages that have not been...
0
by: Programatix | last post by:
Hi, I am working on the PrintDocument, PrintDialog, PageSetupDialog and PrintPreviewControl components of Visual Studio .NET 2003. My developement machine is running Windows XP. There are...
9
by: Jody Gelowitz | last post by:
I am trying to find the definition of "Safe Printing" and cannot find out exactly what this entitles. The reason is that I am trying to print contents from a single textbox to no avail using the...
4
by: Suzanka | last post by:
Hello, I have an application written in C# on visual studio .NET. It is a web aplication. The application consists of many different forms, that users occassionaly want to print out for filing....
4
by: Arif | last post by:
I C# code prints very slow as compared to a third party barcode printing software. That software prints approximately 10 labels in 2 seconds while my C# code prints 10 labels in 5 to 6 seconds. And...
6
by: Siv | last post by:
Hi, I am getting into printing with VB.NET 2005 and want to implement the usual capability that a user can select a selection of pages. I have a report that is generated by my application that if...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
0
by: nikhilgargi | last post by:
Requirement: I need to provide printing capability in a C# desktop application that I am developing The documents that need to be printed can be in Rich Text Format (RTF) or HTML. Custom...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
it0ny
by: it0ny | last post by:
Hi guys, thanks I am fairly new to this forum so I hope I chose the right place to post this question. I try to make my program printout a deposit's report. I created a class to store the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.