Print UPC-A without elongated guard bars using ZPL - zpl

I'm trying to print a UPC-A barcode from a Zebra printer using ZPL.
It always comes out with elongated guard bars like this:
I need it to print like a Code 128 style where all the lines are the same length but encoded UPC-A style:
Here is a basic ZPL:
^XA
^BY3^BUN,70,N,N,N,A
^FD42222200439^FS
^XZ
Any ideas? Thanks.

The only way I have seen to get rid of the descents on the guard bars is to draw over them with a white rectangle. This is straightforward to do with UPC-A since it is a fixed width barcode (95 modules wide) and the descenders are 5 modules in height. Since you are using ^BY3, we need to multiply those numbers by 3, giving a width of 285px and a height of 15px for the descenders.
The example below uses ^FT to position the barcode by its lower left corner. Note that guard bars extend below that position. Then we draw a white rectangle on top of the guard bar descents at the same origin, this time using ^FO:
^XA
^FT50,200^BY3^BUN,70,N,N,N^FD42222200439^FS
^FO50,200^GB285,15,15,W^FS
^XZ
Here is how it looks using the labelary emulator.

Related

ChartJS - x axis labels orientation

Is it possible to change x-axis label orientation like marked area on the screenshot? I was trying rotate labels with afterCalculateTickRotation but they weren't flipped. Mirror option doesn't work also.
Example code
I managed to do what you are asking for but it's not beautiful because chart.js lacks support to do it properly. So I solved it with some hard coded padding.
https://codesandbox.io/s/vue-template-4ygr1
It's the minRotation and maxRotation you should work with. The labels anchoring point should shift when the rotation goes below zero but they don't. Instead they rotate into the chart but this can be avoided with padding.
A side effect of the padding is that the legend placement broke so i put it in the top instead.
Another unwanted behavior is that the text is aligned to the right. There is an open issue about that: https://github.com/chartjs/Chart.js/issues/4193

Xcode Image Slicing Not Working with Gradients?

I have PNG images with rounded corners, inner shadows and a fill gradient, that I thought I could slice in Asset Catalogs horizontal and vertically. But no matter what I try, the gradient slice doesn't stretch or tile as I expected. With Xcode 9.1.
The gradient is not copied (although the inner shadow is), and in IB and the simulator, there are just two bars and no gradient.
What am I missing?
Here are the original image:
Here's how I sliced them:
And what they looked like in IB:
And here's what it looks like in IB (with the colors reversed in the simulator (with a red view and another similar image as background without any gradient) and device.
The center is the part that is getting tiled. You defined a 1x1 square that’s getting repeated on the interior of your image in order to make the image fill the space you defined, which isn’t your stated goal. What you can do is change your center to Stretches, and increase the center’s height and width to take up everything in your image that doesn’t include your rounded corners end caps.

Xcode 8 Auto Layout Constraints not working as expected. Very basic setup with centering plus an issue with pins. Video attached

I am having trouble getting a grasp on how auto-layout constraints work. In theory, one should be able to add a label to the storyboard, then assign a horizontal centre constraint and it should be centred on all devices, correct? However, when I do that, it does NOT stay centred UNLESS I also add a vertical spacing constraint. However, if I test the app it IS centred (without the vertical spacing constraint). This is causing me great confusion.
Secondly, if I add a text input, expand it to full width, then add pin the left and right side, it does NOT maintain the pins in other views. And instead there is this dotted box inside a solid orange line box which is centred, but the element itself is not.
I am at a loss please help. I have attached a video of me doing it in Xcode. Both issues are in there First the centring issue, next to the pinning issue. Thank you!
VIDEO OF THE ISSUES HERE:
https://vid.me/XxFo
-- Red lines mean Constraints are ambiguous. Yellow means warning, Its show you the runtime demonstration of view.
View need four constraint to satisfy its full position.
x, y, width and height
When you give only center horizontally constraint, this is not enough you have to specify the y position as well. Label get its width and height from its text length and text font size.
Though constraints are ambiguous and in preview you are not getting correct result but once you give center constraint, it will be center at runtime.
Run the app and it should be in center horizontally.

VB6 Shape control BorderWidth >1 with Dash style?

When you set a Shape's BorderWidth > 1 in VB6, the Style is forced to be a plain line.
I'd like a DASHED (or Dotted) border with a thicker (say borderwidth=3) size.
any way to do that without drawing it manually?
Unfortunately not, under the hood a GDI Pen is used to draw the shape and the 1 twip limit is imposed there.
PS_DASH
The pen is dashed. This style is valid only when the pen width
is one or less in device units.
This of course also means you cannot use the GDI API to do it directly for you either.
Perhaps draw a series of lines offset by 1 twip.

How to get a 1 pixel line with NSBezierPath?

I'm developing a custom control. One of the requirements is to draw lines. Although this works, I noticed that my 1 pixel wide lines do not really look like 1 pixel wide lines - I know, they're not really pixels but you know what I mean. They look more like two or three pixels wide. This becomes very apparent when I draw a dashed line with a 1 pixel dash and a 2 pixel gap. The 1 pixel dashes actually look like tiny lines in stead of dots.
I've read the Cocoa Drawing documentation and although Apple mentions the setLineWidth method, changing the line width to values smaller than 1.0 will only make the line look more vague and not thinner.
So, I suspect there's something else influencing the way my lines look.
Any ideas?
Bezier paths are drawn centered on their path, so if you draw a 1 pixel wide path along the X-coordinate, the line actually draws along Y-coordinates { -0.5, 0.5 } The solution is usually to offset the coordinate by 0.5 so that the line is not drawn in the sub pixel boundaries. You should be able to shift your bounding box by 0.5 to get sharper drawing behavior.
Francis McGrew already gave the right answer, but since I did a presentation on this once, I thought I'd add some pictures.
The problem here is that coordinates in Quartz lie at the intersections between pixels. This is fine when filling a rectangle, because every pixel that lies inside the coordinates gets filled. But lines are technically (mathematically!) invisible. To draw them, Quartz has to actually draw a rectangle with the given line width. This rectangle is centered over the coordinates:
So when you ask Quartz to stroke a rectangle with integral coordinates, it has the problem that it can only draw whole pixels. But here you see that we have half pixels. So what it does is it averages the color. For a 50% black (the line color) and 50% white (the background) line, it simply draws each pixel in grey:
This is where your washed-out drawings come from. The fix is now obvious: Don't draw between pixels, and you achieve that by moving your points by half a pixel, so your coordinate is centered over the desired pixel:
Now of course just offsetting may not be what you wanted. Because if you compare the filled variant to the stroked one, the stroke is one pixel larger towards the lower right. If you're e.g. clipping to the rectangle, this will cut off the lower right:
Since people usually expect the rectangle to stroke inside the specified rectangle, what you usually do is that you offset by 0.5 towards the center, so the lower right effectively moves up one pixel. Alternately, many drawing apps offset by 0.5 away from the center, to avoid overlap between the border and the fill (which can look odd when you're drawing with transparency).
Note that this only holds true for 1x screens. 2x Retina screens actually exhibit this problem differently, because each of the pixels below is actually drawn by 4 Retina pixels, which means they can actually draw the half-pixels. However, you still have the same problem if you want a sharp 0.5pt line. Also, since Apple may in the future introduce other Retina screens where e.g. every pixel is made up of 9 Retina pixels (3x), or whatever, you should really not rely on this. Instead, there are now API calls to convert rectangles to "backing aligned", which does this for you, no matter whether you're running 1x, 2x, or a fictitious 3x.
PS - Since I went to the hassle of writing this all up, I've put this up on my web site: http://orangejuiceliberationfront.com/are-your-rectangles-blurry-pale-and-have-rounded-corners/ where I'll update and revise this description and add more images.
The answer is (buried) in the Apple Docs:
"To avoid antialiasing when you draw a one-point-wide horizontal or vertical line, if the line is an odd number of pixels in width, you must offset the position by 0.5 points to either side of a whole-numbered position"
Hidden in Drawing and Printing Guide for iOS: iOS Drawing Concepts, though nothing that specific to be found in the current, standard (OS X) Cocoa Drawing Guide..
As for the effects of invoking setDefaultLineWidth: the docs also state that:
"A width of 0 is interpreted as the thinnest line that can be rendered on a particular device. The actual rendered line width may vary from the specified width by as much as 2 device pixels, depending on the position of the line with respect to the pixel grid and the current anti-aliasing settings. The width of the line may also be affected by scaling factors specified in the current transformation matrix of the active graphics context."
I found some info suggesting that this is caused by anti aliasing. Turning anti aliasing off temporarily is easy:
[[NSGraphicsContext currentContext] setShouldAntialias: NO];
This gives a crisp, 1 pixel line. After drawing just switch it on again.
I tried the solution suggested by Francis McGrew by offsetting the x coordinate with 0.5, however that did not make any difference to the appearance of my line.
EDIT:
To be more specific, I changed x and y coordinates individually and together with an offset of 0.5.
EDIT 2:
I must have done something wrong, as changing the coordinates with an offset of 0.5 actually does work. The end result is better than the one obtained by switching off the anti aliasing so I'll make Francis MsGrew's answer the accepted answer.

Resources