Length of a string

Hi all -

I have a VB.NET application that generates a PS containing text and graphics.  I need to follow, in my VB app, hence a text is printed. More specifically, I have a block of text that will be analyzed under several lines to insert in a fixed-width column.  So I would like to know how much text can I print on the current line before going to the next line. So I need to know the print of a given text segment width.

Is it possible for VB calculate or somehow get (via a call to?) the "stringwidth' of a text string for a given font?

Thanks for your thoughts.  Bob

Bob,

There are probably two ways, at least, to accomplish what you're after, within your VB application:

1. I am not familiar with the capabilities of setting for the text in VB, but I think that you could determine the string or the widths of characters, spaces and to understand the positions of break as long as you have the same font for VB as you do for the work of the PS.

Starting point for VB:

  • Var g As System.Drawing.Graphics = Me.CreateGraphics
  • Dim str As String = "this is the string to get the width of.
    Dim StringSize As SizeF = g.MeasureString (str, Me.Font)

2. you could load widths of characters face (size 1) police of PS in a database table that you could access from VB and multiply the time of widths nominal character size that you set to determine the width of the characters printed, etc. (it is what I am most familiar with. This technique can be extended to include kerning pairs and it requires that your VB application host has installed on the printer fonts or screen PS).

-Marvin

Tags: Adobe PostScript

Similar Questions

  • Length of the string

    Hi all

    I intend to measure the length of the string and the length of the Arc in a gray-scale image. Please advise.

    You need to find to the first circle or outer circle?

    Part of Mathematics:

    The length of the rope of calculation, to find the RADIUS and the angle under which is seen in the center of the rope or perpendicular to the distance between the string and the center of the circle: once you have these settings, you can calculate the length of the rope using formulas:

    Source: http://www.mathopenref.com/chord.html

    Similarly, you can get for the length of the Arc: http://www.mathopenref.com/arclength.html

    Part of image processing:

    -I think that you can get the radius of the internal or external circle based on your requirement, using IMAQ detect forms.

    https://zone.NI.com/reference/en-XX/help/370281M-01/imaqvision/imaq_detect_shapes/

  • flatten channel adds the length of the string

    Hi all

    I flatten a cluster chain help to flatten to string.vi. The cluster contains strings and arrays. The flattened string contains the length of the string that is appended to the string.

    So if I have a cluster with only 1 string and a value = "LabVIEW". the flattened string would be "0007LabVIEW". Flatten channel vi has a Boolean entry "add string or array of size? even if I set the Boolean value false, it always adds the length of the string. Is this a bug?

    I think that if you read the detailed help to flatten it to string function you will see this is not a bug.  That boolean applies only to top-level data, once put you something in a cluster or array, the Paris are open.

  • Length of the string, excluding the input character/string

    Long story short, I want to replicate the function of the length of the string , but do not include an input the number of characters in string. For example:

    The input string (search) is 'the

    My first string to test is "the big red dog."

    That would mean a 13 string length.

    My second string is "Jumps over the lazy Fox."

    That would mean a length of 21.

    ' Hello World! ' would return 12.

    'The Lion, the Witch and the wardrobe' would return 26.

    I hope that you can see what I want to achieve. How is this possible?

    -James

    (I'm driving Labview 8.5)

    Use the search and replace the string to replace your 'exclusive' with an empty string string.  Use the length of the string on the result string.  Make sure that everything is already set to TRUE.

  • How cut the length of the string IE channel name here, if it exceeds 20 characters or letters. The channel name is dynamically analyzed the spreadsheet/xml file.

    How cut the length of the string IE channel name here, if it exceeds 20 characters or letters. The channel name is dynamically analyzed the spreadsheet/xml file.

    My Council of Europe in the .js file is

    function generateHTMLMarkup (i, channel) {}
    Alert ("this is lang" + str);
    var str ="";
    "Str += '.

    ";
    "Str += '.
    "+ ""+""+"
    ";
    Alert ("this is lang" + str);
    return str;

    }

    nerateHTMLMarkup: function (i, channel) {}
    Alert ("this is lang" + str);
    var str ="";
    "Str += '.

    ";
    str += "" +
    "" +
    "" + channel ['name'] + "" +.
    "" + "
    ";
    "Str += '.
    "+ "" + "
    ";
    Alert ("this is lang" + str);
    return str;

    etc.

    Give mthe rhythm and the exact code where Ihave tio get implemented.

    in the code, replace change

    channelName var = channel ['name'];

    TO

    channelName var = channel ['name'];

  • Is there a function to adjust the length of a string to 8 multiple bytes?

    Hello

    I have a function to encrypt a password.

    FUNCTION encodeit (p_name IN VARCHAR2, p_password IN VARCHAR2) RETURN VARCHAR2
       IS
          l_password   VARCHAR2 (4000);
          l_salt       VARCHAR2 (4000) := 'hdjikndbbhitasuihfnnkqyhiplwmneuyndnloidj';
       BEGIN
          l_password :=
             UTL_RAW.cast_to_raw (
                DBMS_OBFUSCATION_TOOLKIT.md5 (
                   input_string => p_password ||
                                   SUBSTR (l_salt, 10, 13)||
                                   LOWER (p_name)||
                                   SUBSTR (l_salt, 4, 10)));
          RETURN l_password;
       END;
    

    I want to decrypt the password to send to users when they forget it.  I wrote this function:

    FUNCTION decodeit (p_name IN VARCHAR2, p_password in VARCHAR2) RETURN VARCHAR2 IS
        l_salt       VARCHAR2 (4000) := 'hdjikndbbhitasuihfnnkqyhiplwmneuyndnloidj';
        BEGIN
          RETURN DBMS_OBFUSCATION_TOOLKIT.desdecrypt(input_string =>  p_password ||
                                                                      SUBSTR (l_salt, 10, 13)||
                                                                      LOWER (p_name)||
                                                                      SUBSTR (l_salt, 4, 10),
                                                     key_string   => l_salt) ;
        END;
    

    The problem is that the DBMS_OBFUSCATION_TOOLKIT.desdecrypt function needs a multiple of the input string of 8 bytes. And p_name and p_password are not of fixed length. Is there a function to adjust the length of a string to 8 multiple bytes?

    Best regards.

    They used to work - could be almost ten years (I think version 9 - not tested yet)

    As you can see, you can 'encode' the number of characters, padded in order to set the right length of the decrypted string


    create or replace FUNCTION ' CRYPTIN "(p_str in varchar2) return varchar2 as". "

    l_data VARCHAR2 (255);

    function pad_DES (p_string in varchar2) return varchar2 is

    -platelets p_string with pad_chr containing the number of characters padded (1 to 8)

    -make the string length a multiple of 8 as required by decipher

    pad_length pls_integer;

    pad_char char: = chr (0);

    pad_chars varchar2 (8);

    Start

    pad_length: = 8 - mod (length (p_string), 8);

    pad_chars: = chr (pad_length);

    Return concat (p_string, rpad (pad_chars, pad_length, pad_chars));

    end;

    Start

    l_data: = pad_DES (p_str);

    dbms_obfuscation_toolkit. Decrypt (input_string-online l_data, key_string => 'MagicKey' encrypted_string-online l_data);

    return UTL_RAW. CAST_TO_RAW (l_data);

    end;

    create or replace FUNCTION ' CRYPTOUT "(p_str in varchar2) return varchar2 as". "

    l_data VARCHAR2 (255);

    function unpad_DES (p_string in varchar2) return varchar2 is

    -Removes from p_string upholstered characters (1 to 8)

    pad_length pls_integer;

    Start

    pad_length: = length (p_string);

    pad_length: = pad_length - ascii (substr(p_string,pad_length,1));

    Return substr(p_string,1,pad_length);

    end;

    Start

    l_data: = p_str;

    dbms_obfuscation_toolkit. DESDecrypt (input_string-online l_data, key_string => 'MagicKey', decrypted_string-online l_data);

    Return unpad_DES (l_data);

    end;

    Concerning

    Etbin

  • Lesson1 solutions, length of the string, really a God's solution?

    Hello, I was just looking at the solutions proposed for lesson 1 homework and I came on line 65, ex 2 solution where odd length of the string is calculated this way:

    (s.length () & 1) == 1

    Here, we are a group of users of Java for a long time and we still don't completely understand how it really works.

    Do the bitwise AND operation on the length of the string 1 and audit, seems really strange.

    Either way, I suppose it works somehow but is it really a good solution providing a code which may include only a Ninja of Java for the black belt? If you use it in production which will be able to keep it?

    the pit of my ignorance, I wrote this:

    ! (p.length (% 2) == 0)

    Thank you and have a nice day!

    It's probably again my fault.

    I remember presenting examples of lambda at the beginning I used (I % 2 == 0) to test whether a number has been the same. One of our graphics guys chastises me for using rest (%) instead of bits - and ((i & 1) == 0). In C, the remainder operator is usually compiled to some form of a division operation, which is much slower than a - bit operation and exploitation. (An optimizer may be able to replace i with i 2% & 1 but optimizations in c may be quite subtle). In any case, I started to use at the level of the ILO - and in my examples.

    Then I started getting complaints about the use of the bitwise operators because nobody knew how they worked.

    In any case, in Java, the result is well-defined, as a type int is specified as a 32 bit two complement binary number, so I & 1 will tell you if it's odd or even. The force JIT compiler - reduce i % 2 to i & 1, but when the interpreter is running it will go through the slow lane. As someone said, it's a micro-optimisation anyway.

    A ride is what % is the operator remains , not a modulo operator, while for positive numbers, the result is the same. For negative numbers, the result can be negative! So, be sure to not try for an odd number using i % 2 == 1 because it will fail for an odd, negative number, the result will be-1. Test! = 0, or better still simply use at the level of the ILO - and. Of course, the string length is not a problem because it is still not negative, but the problem may occur in other situations, in particular array of indexation.

  • get the length of each string in a column

    Hi all

    Is there a way to get the length of each string in a column:

    for example:

    If the table contains lines like below:

    Select 'test test1 test31' col1 of double

    Union of all the

    Select 'sectest1 sectest234' double col1

    The output should be as below:

    col1

    ------------

    4 5 6

    8 10

    That is to say get the count of each separated from the chain of space in a column. Is this possible using regexpr_substr?

    Thanks in advance.

    Roy.

    Try the below

    SELECT LISTAGG(val1,' ') IN ONE GROUP)

    New_val ORDER BY lvl)

    Of

    (SELECT LENGTH (REGEXP_SUBSTR (col1,'[^] +', 1, LEVEL)) val1,)

    RN,

    LEVEL lvl

    Of

    (SELECT col1,

    ROWNUM rn

    Of

    (SELECT 'test test1 test31' col1 OF double)

    UNION ALL

    SELECT 'sectest1 sectest234' double col1

    )

    )

    CONNECT BY LEVEL<= regexp_count(col1,'="">

    AND PRIOR rn = rn

    AND PRIOR DBMS_RANDOM. VALUE IS NOT NULL

    )

    GROUP BY rn;

    OUTPUT:-

    =======

    col1

    ----

    4 5 6

    8 10

    Thank you

    Ann

  • How to get the length of the string a vm?

    Hello

    I'm trying to automate some consolidation of virtual machines and would like to add script. I have over 800 virtual machines manually would not work.

    I would like to

    $allVApps = get-CIVApp

    foreach ($CIVm to ($allVApps |)) Get - CIVM)) {}

    find the number of channels and if greater than 8 consolidate them.

    }

    Someone has this practice? or something else?

    I'm in a cloud environment vSphere 5.5, installed latest powercli.

    Thank you

    Don't know why this does not work for others, but what I posted before work for me.  Here is a more complete version of how get the those of VAPP VM.  There are no doubt more direct ways, but that how I made it so far:

    1. get the VAPP

    $vApp = get-CIvApp-name 'Test-VAPP.

    2. get the VMS of vApp

    $VMs = $vApps.ExtensionData.Children.vm

    3. get the ones for the VM first in the list of $VMs:

    $VMs [0]. VCloudExtension.any.VirtualDisksMaxChainLength

    This last command returns 18 for me which is the "Length of the string" value in the properties of the Virtual Machine to the virtual machine in the vCD UI.

    I hope this helps.

  • find the length of the string

    Hi all

    I have a srting that contains two or more channels as for instance, it's my channel (think of this total string as one string) "Bronson, Ms. Jamie", "elder, Ms. Francis '.
    Now I want to calculate the length of the string of replacement of commas and apostrophes with null.

    Can someone pls help me with this?

    Thank you
    SQL>
      1  with t as (
      2   select '''Bronson, Ms. Jamie'',''Elder, Mrs. Francis''' as mystring
      3  from dual)
      4  select * from t;
    
    MYSTRING
    ------------------------------------------
    'Bronson, Ms. Jamie','Elder, Mrs. Francis'  
    
    SQL>
      1  with t as (
      2   select '''Bronson, Ms. Jamie'',''Elder, Mrs. Francis''' as mystring
      3  from dual)
      4  select replace(replace(mystring, ',', null), '''', null) from t;
    
    REPLACE(REPLACE(MYSTRING,',',NULL),
    -----------------------------------
    Bronson Ms. JamieElder Mrs. Francis
    
    SQL> l
      1  with t as (
      2   select '''Bronson, Ms. Jamie'',''Elder, Mrs. Francis''' as mystring
      3  from dual)
      4  select length(replace(replace(mystring, ',', null), '''', null)) as string_len from t;
    
    STRING_LEN
    ----------
            35  
    
  • createTextField setting width based on the length of the string

    I wonder if there is a way to easily calculate how wide to make a textfield you create dynamically with createTextField based on the length of a string that is passed as an argument. In other words, if you know you are going to use the font size, is there a way to know how many pixels you need? Thanks in advance to anyone who can offer assistance.

    have you looked into "TextField.autoSize?

    SPGAnne wrote:
    > I wonder if there is a way to easily calculate how wide to make a textfield
    > you create dynamically with createTextField based on the length of a
    > string passed as an argument. In other words, if you know the police
    > size you plan to use, is there a way to know how many pixels you need?
    > Thanks in advance to anyone who can offer assistance.
    >

  • How to determine the length of the string when the string using LabVIEW MoveBlock pointer dereference

    Hello!

    Calling a DLL that returns a pointer to a structure consisting of a pointer to a string, a 32-bit integer and a pointer to another string.

    I managed to MoveBlock to return a consolidation of these three things, and which works very well.

    But now I need to read the two strings I have pointers to which are not fixed length. MoveBlock has a size of entry, but how to know how long channels are?

    Try this:

    ...\vi.lib\Utility\importsl\GetValueByPointer\GetValueByPointer.XNode

    Wire just a constant string to the Type of entry.  If I remember correctly, the draw of endpoint (assuming that the C strings) will be included.

    Sometimes I have just MoveBlock a byte at a time until I get to a null value or has specified maximum size.

  • Length of a string pixel

    Hello. Anyway we can get the length (not characters but in pixels) of a string? I have the title for a custom field that should be centered. Thank you.

    Focus on the methods of Font.getAdvance. There are also Field.FIELD_HCENTER and DrawStyle.HCENTER - read about them, learning differences, see if they can be applied.

  • Change in length of custom string

    Hello.

    I need to change the length o a field custom_string in the call to the login screen.

    Default value is varchar (30)

    I also checked the change by changing a value in column of record of appeal to a String > 30 and made a request to verify that he had saved the long value.

    So far so good.

    Then I opened the call published in MSM and the time wherever I did (even before recording), the SQL value is truncated to 30 characters.

    It seems as if the GUI has some built in the truncation.  Audit of the field of screen Designer is not a mask (I also tested edit mask with more than 30 alaphanums (*)) and the field size is very large.
    Any suggestions?

    PS, I haven't restarted the server given that current users of another VSM DB on the same machine.

    Thank you

    It is not necessary to restart the server in your case.

    According to me, all you need is to analyze query files (in the VSM Server Console) and recycle the AppPool IIS VSM.

  • Length of the string to Oracle error with exec immidiate limit?

    Hi all

    I can't run the sp DDL statement as < run immediately d_string >, where length (d_strign) = 8655b (d_string varchar2 (9000)).
    If I cut it at 5400 it works OK, I tried to do as much direct < immediate exec 'create view '. "> and < run immeidate d_string >. Complain for lack of right ")" which has been cut, according to me.
    The entire statement (8655 (b) works OK in the query window.

    Is there a limit in this case, I know not 4000 b but I thought that it is for display only, I can't go lower than my 8655b and it should be in the PS, is the ddl to create a complex view.
    I can probably do through intermediate table of TWG or something but I'd rather keep in one piece.

    Is this feasible?

    help much appreciated.


    Best
    Trent

    Trento wrote:
    Hi all

    I can't run DDL statement of Ms as , where length (d_strign) = 8655b (d_string varchar2 (9000)).
    If I cut it at 5400 it works OK, I tried to direct and . Complain for lack of right ")" which has been cut, according to me.

    The thought is not the best way to determine the error. Prove it is.

    I guess the question is not not from any string bing 'cut', but more to do with a query/DDL generated dynamically missing one ")" somewhere in it.
    Try to use DBMS_OUTPUT. Put_line to display the generated DDL/query and see if it is syntactically correct.

  • How to check the length of the string (from viewobject) attribute on jspx?

    Hello

    JDEV: 11.1.1.4

    I use the component of the carousel, inside, I use the Description attribute to display the content about to carousel,
    Now, I want to display a link as well, whenever the length of the description is longer than 150 characters.

    Currently backing bean that I am setting the property chklength to true or false, but the problem, the length is that I need a partial target
    and that's my Carousel component I get updated every time... is possible to check the length in page jspx itself inside the vissible property

    This is my code
    <af:outputText value="#{item.bindings.Descrip.inputValue}"
                                                             id="ot49"/>
                                               <af:commandImageLink text="more.." id="moreid" shortDesc="click to see more.." 
                                                                     visible="#{pageFlowScope.chklength}">
                                                <af:showPopupBehavior popupId="::p1"/>
                                                </af:commandImageLink>              
    Thank you
    Guillet

    You can try with # instead of $?

    visible = "#{FN: length (Item.Bindings.descrip.inputValue) > 150} '"

    Thank you
    Nini

Maybe you are looking for

  • Satellite M40X base memory replacement

    I have a parity error on my base memory and get the Windows blue screen with the error massage at any time. This memory can not officially replaced by the user. Then this memory being replaced without replacing the motherboard? Are the avilable to re

  • my ipod is disabled. I will lose all the photos when I erase

    my ipod is disabled. I understand that I need for recovery, but I lost all my photos?

  • Calc independent PtByPt on the elements of the array

    Hello I have a double table as input, and with each iteration of the main VI, I would calculate the average and standard deviation separately on all the elements using PtByPt VI. Fortunately, in my case, I know that the size of the array is maximum 1

  • VN7 791G - CPU AT FULL LOAD

    Hello I want to ask you that "what cpu temp is adapted on the full load test? I tried on test8 of the pass mark, and some values were critical because the 100% cpu load test I saw 89-90-91 degrees Celsius to 4 cores, is it suitible or not? now, I'm w

  • more b210 HP photosmart will not print on dark paper

    If I use dark paper the printer will just spit and print on the white back.  Is there a setting to allow printing on paper dark?