How can I get height of text block?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Keith G Hicks

    #1

    How can I get height of text block?

    I have a client that I wrote an MS Access app for quite a few years ago
    where they need to know the height in inches of a block of text for billing
    their customers. The MS Access app opens Word in the background, makes some
    settings (font, font size, margins, etc.) and gets the height. It's all
    worked quite well for 3 or 4 years.

    However, the whole thing is going to be redone for use in browsers in
    asp.net with vb.net. We want to eliminate the need to use Word for this. I'd
    like to write a function in vb.net for this. The whole thing is going to be
    run on both Windows and Mac machines. I found some info here:


    8.html

    but I'm not sure it's the correct approach. I was hoping someone
    could point me in the right direction.

    Thanks,

    Keith



  • Armin Zingler

    #2
    Re: How can I get height of text block?

    "Keith G Hicks" <krh@comcast.ne tschrieb
    I have a client that I wrote an MS Access app for quite a few years
    ago where they need to know the height in inches of a block of text
    for billing their customers. The MS Access app opens Word in the
    background, makes some settings (font, font size, margins, etc.) and
    gets the height. It's all worked quite well for 3 or 4 years.
    >
    However, the whole thing is going to be redone for use in browsers
    in asp.net with vb.net. We want to eliminate the need to use Word
    for this. I'd like to write a function in vb.net for this. The whole
    thing is going to be run on both Windows and Mac machines. I found
    some info here:
    >

    8.html
    Login required. Anyway, the size of the text on which device on which
    machine using which dpi settings and which font do you want to
    calculate? I won't be able to give an ASP.Net specific answer but I
    think the questions must be asked first.
    but I'm not sure it's the correct approach. I was hoping someone
    could point me in the right direction.

    Armin

    Comment

    • Keith G Hicks

      #3
      Re: How can I get height of text block?

      If you scroll down to the bottom end of the page in that URL, you'll see
      answers. Login is only required for the "expert's" answers. There are other
      answers that anyone can see below all the advertising. I'm not a subscriber
      either and I get answers from there quite often.

      Also, I should have mentioned that the font and other settings are specific
      to get the length. It's not dependent on what the text comes in as. In the
      Word code we're using now, I set the font to Arial 7, single spaced, 0
      spacing before and after paragraphs, text width is set to 1.5 inches by
      setting page size and margins. Then I can get the exact height of the text
      in inches. That's pretty much wath I need to do in vb.net but without Word.
      Height will be based on the same settings font, text width and paragraph
      settings. In this respect it's a bit different than the question the user
      had on the URL I included.

      Keith

      "Armin Zingler" <az.nospam@free net.dewrote in message
      news:uAZbh6MwIH A.5472@TK2MSFTN GP06.phx.gbl...
      "Keith G Hicks" <krh@comcast.ne tschrieb
      I have a client that I wrote an MS Access app for quite a few years
      ago where they need to know the height in inches of a block of text
      for billing their customers. The MS Access app opens Word in the
      background, makes some settings (font, font size, margins, etc.) and
      gets the height. It's all worked quite well for 3 or 4 years.

      However, the whole thing is going to be redone for use in browsers
      in asp.net with vb.net. We want to eliminate the need to use Word
      for this. I'd like to write a function in vb.net for this. The whole
      thing is going to be run on both Windows and Mac machines. I found
      some info here:
      http://www.experts-exchange.com/Prog....NET/Q_2182000
      8.html
      >
      Login required. Anyway, the size of the text on which device on which
      machine using which dpi settings and which font do you want to
      calculate? I won't be able to give an ASP.Net specific answer but I
      think the questions must be asked first.
      >
      but I'm not sure it's the correct approach. I was hoping someone
      could point me in the right direction.
      >
      >
      Armin
      >

      Comment

      • jeff

        #4
        Re: How can I get height of text block?


        why not solve the real problem ... why do they need the 'hieght' of a text
        block? I assume it is for reporting and not 'Your text hiegh is 2.4 inches'
        .... are you dynamically changing a report, margins, locations ... based on
        this hieght? Answer that question first, and design accordingly.

        Otherwise, I am not sure how you would/could go about this ... build an
        label set to auto size ... fill it with text ... adjust the width ... get
        the hight?

        Jeff.
        "Keith G Hicks" <krh@comcast.ne twrote in message
        news:%23uPvriNw IHA.1236@TK2MSF TNGP02.phx.gbl. ..
        If you scroll down to the bottom end of the page in that URL, you'll see
        answers. Login is only required for the "expert's" answers. There are
        other
        answers that anyone can see below all the advertising. I'm not a
        subscriber
        either and I get answers from there quite often.
        >
        Also, I should have mentioned that the font and other settings are
        specific
        to get the length. It's not dependent on what the text comes in as. In the
        Word code we're using now, I set the font to Arial 7, single spaced, 0
        spacing before and after paragraphs, text width is set to 1.5 inches by
        setting page size and margins. Then I can get the exact height of the text
        in inches. That's pretty much wath I need to do in vb.net but without
        Word.
        Height will be based on the same settings font, text width and paragraph
        settings. In this respect it's a bit different than the question the user
        had on the URL I included.
        >
        Keith
        >
        "Armin Zingler" <az.nospam@free net.dewrote in message
        news:uAZbh6MwIH A.5472@TK2MSFTN GP06.phx.gbl...
        >"Keith G Hicks" <krh@comcast.ne tschrieb
        I have a client that I wrote an MS Access app for quite a few years
        ago where they need to know the height in inches of a block of text
        for billing their customers. The MS Access app opens Word in the
        background, makes some settings (font, font size, margins, etc.) and
        gets the height. It's all worked quite well for 3 or 4 years.
        >
        However, the whole thing is going to be redone for use in browsers
        in asp.net with vb.net. We want to eliminate the need to use Word
        for this. I'd like to write a function in vb.net for this. The whole
        thing is going to be run on both Windows and Mac machines. I found
        some info here:
        >
        >
        http://www.experts-exchange.com/Prog....NET/Q_2182000
        8.html
        >>
        >Login required. Anyway, the size of the text on which device on which
        >machine using which dpi settings and which font do you want to
        >calculate? I won't be able to give an ASP.Net specific answer but I
        >think the questions must be asked first.
        >>
        but I'm not sure it's the correct approach. I was hoping someone
        could point me in the right direction.
        >>
        >>
        >Armin
        >>
        >
        >

        Comment

        • Keith G Hicks

          #5
          Re: How can I get height of text block?

          *WRONG* ASSUMPTION!
          I STATED THE *REAL* PROBLEM.
          I NEED THE HEIGHT OF THE BLOCK OF TEXT.
          IT'S FOR A NEWSPAPER (not that I should have to say that really).
          THEY NEED TO KNOW HOW MANY INCHES TALL THE TEXT IS FOR EACH ADVERTISEMENT
          WHEN SET TO ARIAL 7 POINT, ETC.
          IT'S FOR BILLING PURPOSES.

          Keith

          "jeff" <jhersey at allnorth dottt comwrote in message
          news:#rMpLISwIH A.5124@TK2MSFTN GP04.phx.gbl...
          >
          why not solve the real problem ... why do they need the 'hieght' of a text
          block? I assume it is for reporting and not 'Your text hiegh is 2.4
          inches'
          ... are you dynamically changing a report, margins, locations ... based on
          this hieght? Answer that question first, and design accordingly.
          >
          Otherwise, I am not sure how you would/could go about this ... build an
          label set to auto size ... fill it with text ... adjust the width ... get
          the hight?
          >
          Jeff.
          "Keith G Hicks" <krh@comcast.ne twrote in message
          news:%23uPvriNw IHA.1236@TK2MSF TNGP02.phx.gbl. ..
          If you scroll down to the bottom end of the page in that URL, you'll see
          answers. Login is only required for the "expert's" answers. There are
          other
          answers that anyone can see below all the advertising. I'm not a
          subscriber
          either and I get answers from there quite often.

          Also, I should have mentioned that the font and other settings are
          specific
          to get the length. It's not dependent on what the text comes in as. In
          the
          Word code we're using now, I set the font to Arial 7, single spaced, 0
          spacing before and after paragraphs, text width is set to 1.5 inches by
          setting page size and margins. Then I can get the exact height of the
          text
          in inches. That's pretty much wath I need to do in vb.net but without
          Word.
          Height will be based on the same settings font, text width and paragraph
          settings. In this respect it's a bit different than the question the
          user
          had on the URL I included.

          Keith

          "Armin Zingler" <az.nospam@free net.dewrote in message
          news:uAZbh6MwIH A.5472@TK2MSFTN GP06.phx.gbl...
          "Keith G Hicks" <krh@comcast.ne tschrieb
          I have a client that I wrote an MS Access app for quite a few years
          ago where they need to know the height in inches of a block of text
          for billing their customers. The MS Access app opens Word in the
          background, makes some settings (font, font size, margins, etc.) and
          gets the height. It's all worked quite well for 3 or 4 years.

          However, the whole thing is going to be redone for use in browsers
          in asp.net with vb.net. We want to eliminate the need to use Word
          for this. I'd like to write a function in vb.net for this. The whole
          thing is going to be run on both Windows and Mac machines. I found
          some info here:
          http://www.experts-exchange.com/Prog....NET/Q_2182000
          8.html
          >
          Login required. Anyway, the size of the text on which device on which
          machine using which dpi settings and which font do you want to
          calculate? I won't be able to give an ASP.Net specific answer but I
          think the questions must be asked first.
          >
          but I'm not sure it's the correct approach. I was hoping someone
          could point me in the right direction.
          >
          >
          Armin
          >
          >
          >

          Comment

          • jeff

            #6
            Re: How can I get height of text block?


            thanks for pointing that out ...

            webservice ... use same logic you have today ... install word on the web
            server ... if you have control of installations on the web server.

            or use the approach outlined in the noted document ... again, wrap it up in
            a webservice.

            Jeff.





            "Keith G Hicks" <krh@comcast.ne twrote in message
            news:OBPJtVSwIH A.2208@TK2MSFTN GP04.phx.gbl...
            *WRONG* ASSUMPTION!
            I STATED THE *REAL* PROBLEM.
            I NEED THE HEIGHT OF THE BLOCK OF TEXT.
            IT'S FOR A NEWSPAPER (not that I should have to say that really).
            THEY NEED TO KNOW HOW MANY INCHES TALL THE TEXT IS FOR EACH ADVERTISEMENT
            WHEN SET TO ARIAL 7 POINT, ETC.
            IT'S FOR BILLING PURPOSES.
            >
            Keith
            >
            "jeff" <jhersey at allnorth dottt comwrote in message
            news:#rMpLISwIH A.5124@TK2MSFTN GP04.phx.gbl...
            >>
            >why not solve the real problem ... why do they need the 'hieght' of a
            >text
            >block? I assume it is for reporting and not 'Your text hiegh is 2.4
            inches'
            >... are you dynamically changing a report, margins, locations ... based
            >on
            >this hieght? Answer that question first, and design accordingly.
            >>
            >Otherwise, I am not sure how you would/could go about this ... build an
            >label set to auto size ... fill it with text ... adjust the width ... get
            >the hight?
            >>
            >Jeff.
            >"Keith G Hicks" <krh@comcast.ne twrote in message
            >news:%23uPvriN wIHA.1236@TK2MS FTNGP02.phx.gbl ...
            If you scroll down to the bottom end of the page in that URL, you'll
            see
            answers. Login is only required for the "expert's" answers. There are
            other
            answers that anyone can see below all the advertising. I'm not a
            subscriber
            either and I get answers from there quite often.
            >
            Also, I should have mentioned that the font and other settings are
            specific
            to get the length. It's not dependent on what the text comes in as. In
            the
            Word code we're using now, I set the font to Arial 7, single spaced, 0
            spacing before and after paragraphs, text width is set to 1.5 inches by
            setting page size and margins. Then I can get the exact height of the
            text
            in inches. That's pretty much wath I need to do in vb.net but without
            Word.
            Height will be based on the same settings font, text width and
            paragraph
            settings. In this respect it's a bit different than the question the
            user
            had on the URL I included.
            >
            Keith
            >
            "Armin Zingler" <az.nospam@free net.dewrote in message
            news:uAZbh6MwIH A.5472@TK2MSFTN GP06.phx.gbl...
            >"Keith G Hicks" <krh@comcast.ne tschrieb
            I have a client that I wrote an MS Access app for quite a few years
            ago where they need to know the height in inches of a block of text
            for billing their customers. The MS Access app opens Word in the
            background, makes some settings (font, font size, margins, etc.) and
            gets the height. It's all worked quite well for 3 or 4 years.
            >
            However, the whole thing is going to be redone for use in browsers
            in asp.net with vb.net. We want to eliminate the need to use Word
            for this. I'd like to write a function in vb.net for this. The whole
            thing is going to be run on both Windows and Mac machines. I found
            some info here:
            >
            >
            >
            http://www.experts-exchange.com/Prog....NET/Q_2182000
            8.html
            >>
            >Login required. Anyway, the size of the text on which device on which
            >machine using which dpi settings and which font do you want to
            >calculate? I won't be able to give an ASP.Net specific answer but I
            >think the questions must be asked first.
            >>
            but I'm not sure it's the correct approach. I was hoping someone
            could point me in the right direction.
            >>
            >>
            >Armin
            >>
            >
            >
            >>
            >>
            >
            >

            Comment

            • Armin Zingler

              #7
              Re: How can I get height of text block?

              "Keith G Hicks" <krh@comcast.ne tschrieb
              I set the font to Arial 7, single spaced, 0
              Ummm.. isn't the height = 7 points? (=7/72" inch = 0,0972 inches)

              Sry, no more time ATM.


              Armin

              Comment

              • Michael Leithold, WWK

                #8
                Re: How can I get height of text block?

                On 28 Mai, 15:09, "Keith G Hicks" <k...@comcast.n etwrote:
                I have a client that I wrote an MS Access app for quite a few years ago
                where they need to know the height in inches of a block of text for billing
                Hi there,

                I once did this. We had an application which sized the object
                containing some text too small. So the text was out of bound. I
                calculated the size of the text and adjusted the size of the object.
                You can do this using API calls.



                Michael

                Comment

                • Keith G Hicks

                  #9
                  Re: How can I get height of text block?

                  Should not run Word from server. I was originally going to do that but
                  everything I read says that's a very bad thing to do. Apparently all sorts
                  of problems occur. There's even a page on the MS website where they say that
                  this should not be done as Word is not designed to be run from the server. I
                  don't remember where that is but they strongly advise against it.


                  "jeff" <jhersey at allnorth dottt comwrote in message
                  news:e#1oPiTwIH A.3860@TK2MSFTN GP06.phx.gbl...
                  >
                  thanks for pointing that out ...
                  >
                  webservice ... use same logic you have today ... install word on the web
                  server ... if you have control of installations on the web server.
                  >
                  or use the approach outlined in the noted document ... again, wrap it up
                  in
                  a webservice.
                  >
                  Jeff.
                  >
                  >
                  >
                  >
                  >
                  "Keith G Hicks" <krh@comcast.ne twrote in message
                  news:OBPJtVSwIH A.2208@TK2MSFTN GP04.phx.gbl...
                  *WRONG* ASSUMPTION!
                  I STATED THE *REAL* PROBLEM.
                  I NEED THE HEIGHT OF THE BLOCK OF TEXT.
                  IT'S FOR A NEWSPAPER (not that I should have to say that really).
                  THEY NEED TO KNOW HOW MANY INCHES TALL THE TEXT IS FOR EACH
                  ADVERTISEMENT
                  WHEN SET TO ARIAL 7 POINT, ETC.
                  IT'S FOR BILLING PURPOSES.

                  Keith

                  "jeff" <jhersey at allnorth dottt comwrote in message
                  news:#rMpLISwIH A.5124@TK2MSFTN GP04.phx.gbl...
                  >
                  why not solve the real problem ... why do they need the 'hieght' of a
                  text
                  block? I assume it is for reporting and not 'Your text hiegh is 2.4
                  inches'
                  ... are you dynamically changing a report, margins, locations ... based
                  on
                  this hieght? Answer that question first, and design accordingly.
                  >
                  Otherwise, I am not sure how you would/could go about this ... build an
                  label set to auto size ... fill it with text ... adjust the width ...
                  get
                  the hight?
                  >
                  Jeff.
                  "Keith G Hicks" <krh@comcast.ne twrote in message
                  news:%23uPvriNw IHA.1236@TK2MSF TNGP02.phx.gbl. ..
                  If you scroll down to the bottom end of the page in that URL, you'll
                  see
                  answers. Login is only required for the "expert's" answers. There are
                  other
                  answers that anyone can see below all the advertising. I'm not a
                  subscriber
                  either and I get answers from there quite often.

                  Also, I should have mentioned that the font and other settings are
                  specific
                  to get the length. It's not dependent on what the text comes in as.
                  In
                  the
                  Word code we're using now, I set the font to Arial 7, single spaced,
                  0
                  spacing before and after paragraphs, text width is set to 1.5 inches
                  by
                  setting page size and margins. Then I can get the exact height of the
                  text
                  in inches. That's pretty much wath I need to do in vb.net but without
                  Word.
                  Height will be based on the same settings font, text width and
                  paragraph
                  settings. In this respect it's a bit different than the question the
                  user
                  had on the URL I included.

                  Keith

                  "Armin Zingler" <az.nospam@free net.dewrote in message
                  news:uAZbh6MwIH A.5472@TK2MSFTN GP06.phx.gbl...
                  "Keith G Hicks" <krh@comcast.ne tschrieb
                  I have a client that I wrote an MS Access app for quite a few
                  years
                  ago where they need to know the height in inches of a block of
                  text
                  for billing their customers. The MS Access app opens Word in the
                  background, makes some settings (font, font size, margins, etc.)
                  and
                  gets the height. It's all worked quite well for 3 or 4 years.

                  However, the whole thing is going to be redone for use in browsers
                  in asp.net with vb.net. We want to eliminate the need to use Word
                  for this. I'd like to write a function in vb.net for this. The
                  whole
                  thing is going to be run on both Windows and Mac machines. I found
                  some info here:

                  http://www.experts-exchange.com/Prog....NET/Q_2182000
                  8.html
                  >
                  Login required. Anyway, the size of the text on which device on
                  which
                  machine using which dpi settings and which font do you want to
                  calculate? I won't be able to give an ASP.Net specific answer but I
                  think the questions must be asked first.
                  >
                  but I'm not sure it's the correct approach. I was hoping someone
                  could point me in the right direction.
                  >
                  >
                  Armin
                  >


                  >
                  >
                  >
                  >

                  Comment

                  • Keith G Hicks

                    #10
                    Re: How can I get height of text block?

                    Thanks Michael. This looks promising. I'll look into it later today.

                    Keith

                    "Michael Leithold, WWK" <michael.leitho ld.wwk@googlema il.comwrote in
                    message
                    news:f071e4dd-3b88-4e79-aa27-30bca691f5f4@b1 g2000hsg.google groups.com...
                    On 28 Mai, 15:09, "Keith G Hicks" <k...@comcast.n etwrote:
                    I have a client that I wrote an MS Access app for quite a few years ago
                    where they need to know the height in inches of a block of text for
                    billing
                    >
                    Hi there,
                    >
                    I once did this. We had an application which sized the object
                    containing some text too small. So the text was out of bound. I
                    calculated the size of the text and adjusted the size of the object.
                    You can do this using API calls.
                    >

                    >
                    Michael

                    Comment

                    • Keith G Hicks

                      #11
                      Re: How can I get height of text block?

                      Ummmm.... yes, but what's your point????

                      "Armin Zingler" <az.nospam@free net.dewrote in message
                      news:u2XbrRWwIH A.2360@TK2MSFTN GP05.phx.gbl...
                      "Keith G Hicks" <krh@comcast.ne tschrieb
                      I set the font to Arial 7, single spaced, 0
                      >
                      Ummm.. isn't the height = 7 points? (=7/72" inch = 0,0972 inches)
                      >
                      Sry, no more time ATM.
                      >
                      >
                      Armin

                      Comment

                      • Armin Zingler

                        #12
                        Re: How can I get height of text block?

                        "Keith G Hicks" <krh@comcast.ne tschrieb
                        Accuracy is not as big an issue here as what I expect you had to
                        deal with on your project. They price ads based on 1.5" tall
                        sections. 1.5" is one price, 3" is another, and so on. If an ad were
                        to measure 1.51" in the code I wrote it would be billed as a 3" ad.
                        Now if that ad really printed up in the newspaper as a 1.5" ad they
                        would have of course been overbilled a bit. However, like I said,
                        it's not super critical. Sometimes it works the other way around.
                        And in addtion they make billing corrections for other things as
                        well. It all evens out in the end. Sometimes they're overbilled a
                        fraction and sometimes underbilled. The other problem is that the
                        calculations are done on Windows machines but all the publishing is
                        done on Macs. That obviuosly throws things off a bit too. We knew
                        from the start that it woulnd't be perfect but it's close enough
                        that everyone's been happy with it for sevearl years now. We just
                        need to get the same concept working without using Word. If we're
                        off by a percent or less eitehr way for any given notice, it's ok.
                        I have no doubts that this is all true. However, my point is still the
                        same as in my first reply: The actual size depends on many things. Well,
                        we have Graphics objects to measure text. How can we create one? A
                        Graphics object is a kind of wrapper to a Win32 device context. As the
                        name says, it refers to a device. A printer device? The screen (device)?
                        If you have a Winforms application, you can simply use
                        g=WhateverContr ol.CreateGraphi cs, do g.measuretext and there it is. I
                        have no other clue how to do it. If it's a web project, I don't know if
                        you have access to a "screen device" because everything runs in the web
                        server's account. Have read something about window stations and desktops
                        but you should better ask someone who has more experience in this.

                        ..... Docs say: "When a noninteractive process such as a service
                        application attempts to connect and no window station exists for the
                        process logon session, the system attempts to create a window station
                        and desktop for the session." I read it that you can use
                        "Graphics.FromH wnd(Intptr.Zero )" to create a graphics object even from
                        within a service, then use g.measurestring .

                        Sry, maybe a little confusing from me today.


                        Armin

                        Comment

                        • =?Utf-8?B?U3VydHVyWg==?=

                          #13
                          RE: How can I get height of text block?

                          Graphics.Measur eString() is the function you are after




                          --
                          David Streeter
                          Synchrotech Software
                          Sydney Australia


                          "Keith G Hicks" wrote:
                          I have a client that I wrote an MS Access app for quite a few years ago
                          where they need to know the height in inches of a block of text for billing
                          their customers. The MS Access app opens Word in the background, makes some
                          settings (font, font size, margins, etc.) and gets the height. It's all
                          worked quite well for 3 or 4 years.
                          >
                          However, the whole thing is going to be redone for use in browsers in
                          asp.net with vb.net. We want to eliminate the need to use Word for this. I'd
                          like to write a function in vb.net for this. The whole thing is going to be
                          run on both Windows and Mac machines. I found some info here:
                          >

                          8.html
                          >
                          but I'm not sure it's the correct approach. I was hoping someone
                          could point me in the right direction.
                          >
                          Thanks,
                          >
                          Keith
                          >
                          >
                          >
                          >

                          Comment

                          Working...