How to Print?

  • Thread starter Thread starter Steve Behman
  • Start date Start date
S

Steve Behman

I am writing a program using Visual C++ Express Edition. This program
collects data from the user in a "Form".

What I would like to do is to print that data, in appropriate places, with
the text overlaying an image (.TIF,.gif,...) which is an 8.5 x 11 of the
boilerplate desired on the printed page.

My question is: Is there a *simple* way to accomplish this?

Everything I've been able to find in the "Help System" seems to indicate the
necessity for learning XML which is, at this time, a too trying task for me
to accomplish.
 
I am writing a program using Visual C++ Express Edition. This program
collects data from the user in a "Form".

What I would like to do is to print that data, in appropriate places, with
the text overlaying an image (.TIF,.gif,...) which is an 8.5 x 11 of the
boilerplate desired on the printed page.

My question is: Is there a *simple* way to accomplish this?

Everything I've been able to find in the "Help System" seems to indicate the
necessity for learning XML which is, at this time, a too trying task for me
to accomplish.

No, you don't need XML for that sort of thing. Judging by your
description, you use Windows Forms for your GUI; if that is indeed the
case, you should read the docs on PrintDialog, PrintDocument, and
PrintPreviewControl classes. You only really need PrintDocument, and
specifically its PrintPage event - in it, you get a Graphics object
for the current page, and use the standard APIs from System.Graphics
to draw whatever you want on it.

On a side note, printing a raster image (.tif & .gif are both that) to
a printer is usually not a good idea - it will look blurry when scaled
to printer's DPI. Consider using a vector image (e.g. .wmf/.emf)
instead, or, if it's a simple frame, just drawing it directly from
your code.
 
Pavel, thanks again for the help.

Fortuitously the image has precisely the same resolution as the target
printer, so I don't think that the image will be blurred in any way when
printed.

As concerns "PrintDocument" I have searched everywhere I can think of for
C++ examples of its use -- with no success. The documentation has numerous
examples for everything but C++.

The use of this class seems sufficiently complicated that I am lost without
an example.

Pardon my naïveté, but would you please point me to an example written for
Visual C++?
 
Pavel, thanks again for the help.

Fortuitously the image has precisely the same resolution as the target
printer, so I don't think that the image will be blurred in any way when
printed.

As concerns "PrintDocument" I have searched everywhere I can think of for
C++ examples of its use -- with no success. The documentation has numerous
examples for everything but C++.

The use of this class seems sufficiently complicated that I am lost without
an example.

Pardon my naïveté, but would you please point me to an example written for
Visual C++?

MSDN mostly covers all 3 languages (C#, VB, C++/CLI) in its examples.
Have a look:

http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx

The C++/CLI example is the third from the top - just make sure that
you have the "Language Filter" on the top of the page not set to hide C
++.
 
Steve Behman said:
Pavel, thanks again for the help.

Fortuitously the image has precisely the same resolution as the target
printer, so I don't think that the image will be blurred in any way when
printed.

As concerns "PrintDocument" I have searched everywhere I can think of for
C++ examples of its use -- with no success. The documentation has numerous
examples for everything but C++.

The use of this class seems sufficiently complicated that I am lost
without
an example.

Pardon my naïveté, but would you please point me to an example written for
Visual C++?


In addition to Pavel's reply...

when there's no C++ sample code in the docs, the C# code is pretty much
identical to what you need to do in C++ except for the obvious differences
in the dispose pattern, the scope resolution operator ("::" vs "."), and the
member access operator ("->" vs ".").

Mark
 
Back
Top