How to Print?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?U3RldmUgQmVobWFu?=

    How to Print?

    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.
  • Pavel Minaev

    #2
    Re: How to Print?

    On Aug 14, 7:24 pm, Steve Behman
    <SteveBeh...@di scussions.micro soft.comwrote:
    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
    PrintPreviewCon trol 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.

    Comment

    • =?Utf-8?B?U3RldmUgQmVobWFu?=

      #3
      Re: How to Print?

      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 "PrintDocum ent" 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 Minaev" wrote:
      On Aug 14, 7:24 pm, Steve Behman
      <SteveBeh...@di scussions.micro soft.comwrote:
      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
      PrintPreviewCon trol 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.
      >

      Comment

      • Pavel Minaev

        #4
        Re: How to Print?

        On Aug 15, 1:15 am, Steve Behman
        <SteveBeh...@di scussions.micro soft.comwrote:
        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 "PrintDocum ent" 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:

        Defines a reusable object that sends output to a printer, when printing from a Windows Forms application.


        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
        ++.

        Comment

        • Mark Salsbery [MVP]

          #5
          Re: How to Print?

          "Steve Behman" <SteveBehman@di scussions.micro soft.comwrote in message
          news:981290BD-E19B-4DB7-9C1D-C23A879A77C4@mi crosoft.com...
          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 "PrintDocum ent" 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


          Comment

          Working...