ZPL II and dynamic width of graphic box when reverse printing a field - reverse

I am quite new to the ZPL II language and have some trouble with writing text in reverse mode with the ^GB and ^FR commands. As far as I understood the ZPL language, when I want to print a text in reverse mode (white over black) I have to first draw a graphic box with the ^GB command and then set the field to be written to in reverse mode with the special ^FR command.
The problem I have is that I would like to fit the graphic box's width to the text's width. With the font I use, the ^A0 font, I couldn't find out the algorithm to calculate the correct width of the graphic box.
Depending on the text, if there are numbers or letters or both, the graphic box's width is not just (number of caracters)*(width of one caracter)...
Here is the code I use :
^XA
^FO64,0,^GB70,20,10^FS
^FO64,0,^FR^A0N,32,37^FD0001^FS
^XZ
When using a mix of numbers and letters the graphic box doesn't fit anymore :
^XA
^FO64,0,^GB70,20,10^FS
^FO64,0,^FR^A0N,32,37^FDAW01^FS
^XZ
I would be very grateful to anyone who could give me the correct approach to my problem .

I do not believe that there is a way to make the graphic box auto size based on the actual length of the text. I'd recommend using a mono-spaced font. That should easily allow you to calculate the width of the box based on the number of characters. Use Zebra Utilities to download a mono-spaced font to he printer.

Related

Float or wrap text around a chart?

I've been searching and searching for an answer to my question, but I can't seem to find anything. Does anyone know of a way to wrap/float text around a chart or image in SSRS? I was hoping for some kind of option similar to the blue one below in Word, but no luck there:
I found the following post, which has a good example image of what I'm looking for, but doesn't have any helpful answers (I'm not using Crystal Reports, I'm using BIDS SSRS through Visual Studio 2015).
Crystal report (or SSRS) flowing text around image
I've tried the following:
Overlaying a text box on top of the image (rendering shoves the image below the text)
Trying to find or create a mad scientist algorithm that can split the text after a certain number of characters, but not in the middle of a word, chop off the rest, and continue the rest of the text in a separate textbox under the image (not a mad scientist, so no luck)
Thanks for any tips!
There's no built in way to do this in SSRS.
Someone wrote a function that determines how many pixels are in a given text string.
Truncate textbox content with ellipsis in SSRS
Public Function TextWidth(str As String) AS Double
'Returns the width, in pixels, of a string, assuming Tahoma size 8.
Dim size As System.Drawing.SizeF
Dim font As New system.Drawing.Font("Tahoma", 8)
size = System.Windows.Forms.TextRenderer.MeasureText(str, font)
TextWidth = size.Width
End Function
You may be able to use this to figure out where to make a break in the first text box and spill the rest to the second. You'd just need to do testing to figure out how many pixels of text your first text box holds.
Once you figure out how many pixels would fit (I would just fill the first text box with text then use the function to see how many pixels that text is), change the other TextCap function to return either the first or second part at the pixel split. You could add an Argument in the function to indicate whether to return the first or second part of the text. Then use the function in the first text box to return the first part and the second part in the second text box.
It's a bit of work but seems feasible. It depends on how bad you want it and how much time you have.

VB6 - Dynamically adjust tab width based on Caption length

I am new to VB6 development (I understand it is pretty outdated. But maintaining legacy code).
My question is - is it possible to dynamically adjust the width of a Tab based on it's Caption length (i.e. dynamically flexing the width of the tab)?
Example: My English text for a tab contains 10 characters, but French equivalent text contains like 15-20 characters. Would it be possible to accommodate text in the tab without having empty spaces on either sides of the text in both English and French?
Right click on the ssTab control and select properties. Under the General tab, select ssStylePropertyPage from the Style: drop down and NOT ssStyleTabbedDialog.
This will automatically adjust the size of the caption of all tabs based on the length of their captions.
The TabMaxWidth property is ignored when this is selected.

display text as square symbols instead of letters

Is there a simple css way to display text with every letter replaced with a filled square?
My idea was to find a font-family that has squares for all letters, but I didn't find anything like that existing. Google is no friend as it gives hits of posted issues with boxes that appear when fonts fail in some way.
Letters should be displayed as squares, not replaced with squares. Also, I need to be able to control the square fill color with the usual html/css.
I'm fine to use font-face, but am trying to avoid the learning curve for creating my own font.
Update: here is an example:
div.innerHTML = "some arbitrary text".
Should be displayed like this:
"■■■■ ■■■■■■■■■ ■■■■".
#NoobEditor is right although. Many online font editors available (e.g.: http://fontark.net/farkwp/ ), you can create such font family in few minutes and can embed with your app.
Get a square font, define it in your we page style, asign it to an object, a div must work, put your text there. Voila.

How to measure the size of the text in specific font of specific font size

I would like to do a trimming of the text that I need to display in box on a web page.
The known parameters are Font Family, Font Size, the number of characters to display and the actual text and of course the width of bounding box.
I need to calculate where to trim the source text and where to put "..."
I have an idea but it is not too fast.
If there exist some other way to do the trimming maybe in CSS I would like to know it and I can accept it as a solution too.
You cannot calculate this ahead of time. You need to position the actual text in the browser and measure the output. You can do this off-screen using a negative text-indent if needed.
There are plug-ins for jQuery that can set an ellipsis based on a fixed-sized container with overflow.
See: http://archive.plugins.jquery.com/plugin-tags/ellipsis
So long as you don't need to support older browsers, you could use this simple css:
text-overflow:ellipsis;
http://www.w3schools.com/cssref/css3_pr_text-overflow.aspenter link description here

SSRS 2008 and Dynamic Positioning of Text Boxes

I'm trying to produce a pay check. I will allow the user to setup the position of the items according to their check style.
From my research, it seems that the position of text boxes in SSRS is static and not dynamic. There is no "expression" option for Top/Left. I thought a way to get around this might be to make the text boxes large and overlapping and then set the padding top/left based on expressions to the positions that user has selected. However, it seems that similar to HTML, the text boxes either float around the higher level text boxes or simply drop out of view.
This would be simple if there were a way to tell SSRS not to be concerned with the order of the text boxes and simply display them overlapping, however I don't feel that there is.
Given that, what other options to I have for dynamically positioning text boxes in an SSRS 2008 report? I'm moving right along with this project but I've hit this stumbling block.
SSRS gives you a lot of options for dynamic formatting but Size and Location are fixed. You cannot change this. Overlapping of textboxes does not work in the soft-break renderers like HTML and Excel but does work in hard-break renderers like PDF or TIFF. Have you tried your padding technique and output the report as PDF?
I'm not sure what are going to do in your report, But in similar cases I usually use Space character to position a text. For instance,
IIf(Len(Fields(YourColumn.valu)) > 10, Fields(YourColumn.valu), "    ")
Note that you have to ensure it can implemented in your case or not. I'm not sure that it is helpful but as long as the location and width properties are fix this is the only option
Note 2 : I'm using Unbreakable Space character instead of simple Space so that SSRS render it without any problem