how i can measure width of text entity in Eyeshot Vb.net? - vb.net

I want to measure text width in Vb.net. Just like i have a text entity, i can get or set the text height but unable to get the text width.Just like the text in the code, i want its width , i have set its height to be 0.25 in the constructor.
Dim a As Text
a.TextString = "Ahmad"
a.Height = 0.25
a.Plane = Plane.ZX
a.InsertionPoint = New Point3D(xMinGlobal - 2.5, 0, 1.5)

You can check the BoxSize property of the entity.
If it's Nothing, try calling the Regen() method or adding the text entity to the scene.

Related

Is there a way to set the dimensions of a paragraph in itext7?

Trying to set the height along with setting the rotation on a Paragraph object results in the following error:
ERROR c.i.layout.renderer.BlockRenderer - Rotation was not correctly processed for ParagraphRenderer
Also, the height is sent to infinity resulting in an apparently empty page which I'm not sure if it's the expected behavior or not.
If I don't set the height, the text shows up rotated (which is what I want). But my task is to place the text at certain coordinates with certain dimensions and rotation. The placement is fine, but not being able to set the height results in assigning the rotation points to the wrong values and in turn displacing the final position of the text.
Paragraph paragraph = new Paragraph(text);
paragraph.setHeight(height);
paragraph.setMargins(0, 0, 0, 0);
paragraph.setProperty(ROTATION_POINT_X, x);
paragraph.setProperty(ROTATION_POINT_Y, y);
paragraph.setProperty(ROTATION_ANGLE, asFloat(toRadians(rotation))));
document.add(paragraph);
Setting the margins to 0 doesn't seem to have any influence either. The text looks to keep some sort of margin anyway.
So is there a way to control what the dimensions of the object displayed are? I could also settle for a way to make the rotation pivot from the center of the object.
You should set both width and height at the same time for rotated objects.
Here is an example code:
Paragraph paragraph = new Paragraph("Hello world");
paragraph.setWidth(200);
paragraph.setHeight(20);
paragraph.setBackgroundColor(ColorConstants.RED);
paragraph.setMargins(0, 0, 0, 100);
paragraph.setProperty(ROTATION_POINT_X, paragraph.getWidth().getValue() / 2);
paragraph.setProperty(ROTATION_POINT_Y, paragraph.getHeight().getValue() / 2);
paragraph.setRotationAngle(Math.PI / 180 * 45);
document.add(paragraph);
Visual result:

Label.Autoellipsis text moves up

I'm encountering an issue when using a Label. It has Autosize property set to False, AutoEllipsis property set to True and TextAlign set to MiddleLeft. The Label has also a fixed size of (296, 25).
The problem:
As soon as the text reaches boundary limits it displays "..." but also moves text to the upper corner. I'm assuming this is because label size is greater than the text font, therefore it tries to fit more text within the control. I don't want this behavior. I want text to be single line only and when ellipsis is displayed I want it to remain text position set in properties.
Any ideas how to fix this bug?
You can measure your Label's text Width first and then give some top Padding if Label's Width is smaller. In other words, when Label's AutoEllipsis "happens".
Dim _TextSize As System.Drawing.Size = TextRenderer.MeasureText(YourLabel.Text, YourLabel.Font)
If _TextSize.Width > YourLabel.Width Then
YourLabel.Padding = New Padding(0, 6, 0, 0)
Else
YourLabel.Padding = New Padding(0, 0, 0, 0)
End If

Text Formatting To Avoid Overwritting

I already saw this question but it doesn’t help me.
The problem is that I can write the text to the PDF file, but if I do that with a new gfx.DrawString it put the second text on the first...
like this....
Here is my code I used to set a new line:
gfx.DrawString(lbname.Text + " " + lbnamei.Text, font, XBrushes.Black, new XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
gfx.DrawString(lbvorname.Text + " " + lbvornamei.Text, font, XBrushes.Black, new XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.TopLeft);
I think it has something to do with the numbers in the first argument (new XRect(0, 0,) but it is unclear how to set them.
I can't remember which parameter does which, but this will help you discover for yourself:
Set one of the numbers to 20 on one of the pieces of text; observe the effect. Then change it back and change a different number; observe the effect.
An XRect has the four parameters x, y, width, height. x is the position from the left, y is the position from the top.
Width and height have no effect as long as XStringFormats.TopLeft is used. Therefore it is enough with the code shown above to increment y to draw text in a new line.
Width must be set to have text that is right-aligned or horizontally centered.
Height must be set to have text that is bottom-aligned or vertically centered.

VBA Excel 2010 CreateObject ExtendedProperty get image width attribute

I'm using similar kind of functions to get some property attributes like Filename, bit depth, dimensions, size etc by using some vba code. The last line of that function would be something like the following:
PicSize = CreateObject("Shell.Application").Namespace(vPth2).Parsename(sPic2).ExtendedProperty("size")
Now, I want to get the height and width of that image file. I've put height and width in the ExtendedProperty attribute value but it's not giving me the height and width of that file.
Note that, in the property dialog box of that image file, in the summary tab, it is showing Bit depth but putting this did not work. Then I put bitdepth and it worked successfully. The names are not case sensitive.
Okay! Now all I want to get the height and width of that selected image file. How can I do that? I mean what to put inside ExtendedProperty() to get height and width.
An early reply with solution would be highly appreciated.
Can't help with why Height and Width don't work, but Dimensions seems to work, returns a string like ?493 x 376?
I suggest the work around method
replace size in your code
PicSize=CreateObject("Shell.Application").Namespace(vPth2).Parsename(sPic2).ExtendedProperty("size")
to Dimensions
you will get something like ?493 x 376?
now declare
a string t = "?493 x 376?"
'search the index of "x"
search_x = InStr(t, "x")
'we would got width and height by
width = Mid(t, 2, search_x - 2)
height = Mid(t, search_x + 2, Len(t) - 8)
It is unknow why but I found that start at "2" in width and "-8" in height like that would give a number

Is there a way to resize an MdiTab to fit your newly-updated text? (Infragistics)

I am resetting the text for an MdiTab in an UltraWinTabbedMdi. I reset it to be bold and longer, but the tab does not resize so the text is truncated. Right now, I'm just resetting the size of the tab to some magic number that I've found looks decent on my computer, but I don't know if it will work elsewhere. I would like to be able to get the dimensions of the new text and add the same size to that every time or call some auto-resize method.
Is there a way to do this?
You could use the MeasureString of the Graphics class.
// Set up string.
string measureString = "YourText";
// The font name and size used to draw the string (from your MdiTab)
Font stringFont = new Font("Arial", 16);
// Measure string.
SizeF stringSize = new SizeF();
stringSize = this.Graphics.MeasureString(measureString, stringFont);
// now you have a stringSize.Width and stringSize.Height to use