Calculating text width when printing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack Russell

    #1

    Calculating text width when printing

    Any bright ideas on how I can calculate how wide a piece of text will be
    when printing.
    When writing text to the screen in graphics mode I put it in a invisible
    text box to get its height and width (as suggested on this group).
    But obviously I cannot do that with the printer.

    Thanks
  • Armin Zingler

    #2
    Re: Calculating text width when printing

    "Jack Russell" <jackr@norubbis h.tpg.com.au> schrieb[color=blue]
    > Any bright ideas on how I can calculate how wide a piece of text
    > will be when printing.
    > When writing text to the screen in graphics mode I put it in a
    > invisible text box to get its height and width (as suggested on this
    > group). But obviously I cannot do that with the printer.[/color]

    Call a graphics object's MeasureString method. In the
    PrintDocument.P rintPage event, you get it in e.graphics.
    Before printing you get it from
    System.Drawing. Printing.Printe rSettings.Creat eMeasurementGra phics.

    Armin

    Comment

    • Jack Russell

      #3
      Re: Calculating text width when printing

      Armin Zingler wrote:[color=blue]
      > "Jack Russell" <jackr@norubbis h.tpg.com.au> schrieb
      >[color=green]
      >> Any bright ideas on how I can calculate how wide a piece of text
      >> will be when printing.
      >> When writing text to the screen in graphics mode I put it in a
      >> invisible text box to get its height and width (as suggested on this
      >> group). But obviously I cannot do that with the printer.[/color]
      >
      >
      > Call a graphics object's MeasureString method. In the
      > PrintDocument.P rintPage event, you get it in e.graphics.
      > Before printing you get it from
      > System.Drawing. Printing.Printe rSettings.Creat eMeasurementGra phics.
      >
      > Armin
      >[/color]
      But dont' you have to put the string somewhere to measure it. If I put
      it on the printer how do I get it off if it is too long (or am I missing
      something basic here?).

      Comment

      • Armin Zingler

        #4
        Re: Calculating text width when printing

        "Jack Russell" <jackr@norubbis h.tpg.com.au> schrieb[color=blue]
        > Armin Zingler wrote:[color=green]
        > > "Jack Russell" <jackr@norubbis h.tpg.com.au> schrieb
        > >[color=darkred]
        > > > Any bright ideas on how I can calculate how wide a piece of text
        > > > will be when printing.
        > > > When writing text to the screen in graphics mode I put it in a
        > > > invisible text box to get its height and width (as suggested on
        > > > this group). But obviously I cannot do that with the printer.[/color]
        > >
        > >
        > > Call a graphics object's MeasureString method. In the
        > > PrintDocument.P rintPage event, you get it in e.graphics.
        > > Before printing you get it from
        > > System.Drawing. Printing.Printe rSettings.Creat eMeasurementGra phics.
        > >
        > > Armin
        > >[/color]
        > But dont' you have to put the string somewhere to measure it. If I
        > put it on the printer how do I get it off if it is too long (or am I
        > missing something basic here?).[/color]

        You only have to put it in the call to the function. The function returns
        the size. Then you can check the size to see whether it's too long.

        Armin

        Comment

        • Jack Russell

          #5
          Re: Calculating text width when printing

          Armin Zingler wrote:[color=blue]
          > "Jack Russell" <jackr@norubbis h.tpg.com.au> schrieb
          >[color=green]
          >> Armin Zingler wrote:[color=darkred]
          >> > "Jack Russell" <jackr@norubbis h.tpg.com.au> schrieb
          >> >
          >> > > Any bright ideas on how I can calculate how wide a piece of text
          >> > > will be when printing.
          >> > > When writing text to the screen in graphics mode I put it in a
          >> > > invisible text box to get its height and width (as suggested on
          >> > > this group). But obviously I cannot do that with the printer.
          >> >
          >> >
          >> > Call a graphics object's MeasureString method. In the
          >> > PrintDocument.P rintPage event, you get it in e.graphics.
          >> > Before printing you get it from
          >> > System.Drawing. Printing.Printe rSettings.Creat eMeasurementGra phics.
          >> >
          >> > Armin
          >> >[/color]
          >> But dont' you have to put the string somewhere to measure it. If I
          >> put it on the printer how do I get it off if it is too long (or am I
          >> missing something basic here?).[/color]
          >
          >
          > You only have to put it in the call to the function. The function
          > returns the size. Then you can check the size to see whether it's too long.
          >
          > Armin
          >[/color]
          Thanks,
          There is something about .net that makes me miss the obvious!

          Jack

          Comment

          Working...