how to print zpl barcode vertically in vertical label - php

i am using zebraGk420d printer. i am using vertical barcode label. how to print the text and barcode in vertically. my zpl code like this
$barcode_ZPL_code="^XA
^FO 150,50^AD,40^FH^FDSALABED_20CARGO^FS
^FO80,100^AD^BY2
^BCN,100,Y,N,N
^MD10
^FDLTX81316-1(1)-APP^FS
^FO1,250^A0N,20,20^FH^FDCOURIER_20TYPE_3ACHEDDI_20JAGAN_20AIPORT_20GUYANA_20OWN_20CLEARING_20TEST^FS
^FO1,280^A0N,20,20^FH^FDDESTINATION_3ASALABED_202CARGO_20PLOT_20710_20BLOCK_2012_20KISENYI_20ROAD_2E_2E_2E^FS
^FO1,310^A0N,20,20^FH^FDHEAD_20OFFICE_3AUNIT_204A_20ORBITAL_20BUSINESS_20PARK_205_20ARGON_20ROAD^FS
^FO106,340^A0N,20,20^FH^FDEDMONTON_20LONDON_20N18_203BW_20EMAIL_3AINFO_40SALABED_2ECO_2EUK^FS
^FO106,370^A0N,20,20^FH^FDTEL_3A_2B44_28020_29_208884_204060_20WEBSITE_3AWWW_2ESALABED_2ECO_2EUK^FS
^XZ";
This code prints in horizontal format.Thanks in advance.

You can specify orientation for each text/barcode field individually, for example if some fields should print horizontally and others at 90 degrees, or use a default orientation for all fields, and then only specify orientation for exceptions to that rule.
The individual field orientation in your label for text and barcodes are specified in the fourth letter of ^AON and ^BCN commands. To change the orientation of any of these fields, use the appropriate letter from following list:
N = normal
R = rotated 90 degrees (clockwise)
I = inverted 180 degrees
B = read from bottom up, 270 degrees
For example, to print the barcode at 90 degrees, replace ^BCN,.... to ^BCR,..., or to print a particular text line at 90 degrees, replace ^AON,... to ^AOR,....
To change the default orientation of all fields in your label, you can use ^FWx before any text / barcode fields are called out, where x represents the desired default orientation (from above list of orientation options), and only include the orientation letter in individual text / barcode commands (i.e., change ^BCN,... to ^BC,... and ^AON,... to ^AO,...) for any exceptions to that default orientation.
For example, to print all fields at 90 degrees except the last text line you can use the following (notice the added ^FWR command and the orientation letter removed from all text / barcode fields except the last text command):
$barcode_ZPL_code="^XA
^FWR
^FO 150,50^AD,40^FH^FDSALABED_20CARGO^FS
^FO80,100^AD^BY2
^BC,100,Y,N,N
^MD10
^FDLTX81316-1(1)-APP^FS
^FO1,250^A0,20,20^FH^FDCOURIER_20TYPE_3ACHEDDI_20JAGAN_20AIPORT_20GUYANA_20OWN_20CLEARING_20TEST^FS
^FO1,280^A0,20,20^FH^FDDESTINATION_3ASALABED_202CARGO_20PLOT_20710_20BLOCK_2012_20KISENYI_20ROAD_2E_2E_2E^FS
^FO1,310^A0,20,20^FH^FDHEAD_20OFFICE_3AUNIT_204A_20ORBITAL_20BUSINESS_20PARK_205_20ARGON_20ROAD^FS
^FO106,340^A0,20,20^FH^FDEDMONTON_20LONDON_20N18_203BW_20EMAIL_3AINFO_40SALABED_2ECO_2EUK^FS
^FO106,370^A0N,20,20^FH^FDTEL_3A_2B44_28020_29_208884_204060_20WEBSITE_3AWWW_2ESALABED_2ECO_2EUK^FS
^XZ";
Also, you will need to adjust the x/y coordinates once you change field orientation.

Related

Jpgraph position text at certain x-value position

I'm using JPGraph with a simple Line plot.
It's possible to create a text or image and position it vertically and horizontally centered on a point of my line?
Something like:
$txt = new Text("hello");
$txt->SetPosition????("center",$p1->$index,$shift_x,$shift_y);
it is possible to position the text on a specific point in the graph area by
$txt->SetScalePos(x, y);
where x and y are the coordinations on the X and Y axis.

PHP GD and True Type Font

I have a weird issue with TTF and PHP GD 2.x.
I have a size 45px TTF at top position 100. The top of the text is perfect align with a line (in the image).
BUT if I change the size of the font, the text is no longer align with the line.
At size 20px I need to subtract 5 to the top value of the text and if the font is size 300px I need to add 56 to the top value to get the perfect alignment.
And the worse if I change font (another TTF) it's the same but with different number.
Did I miss something. Why I need to change the top value of the text depending of the size of it and why the number I have for one font is not the same as another one?????
And if all that is normal. How can I get a formula to always get the text align on the line.
Here some number....
Font 1 . size 20 = top 95, size 45 = top 100, size 300 = top 156.
Font 2 . size 20 = top 91, size 193 = top 100, size 300 = top 105.
I'm not so good in math....sad
Thanks
Bill
You'd be better off using Imagick, which lets you query the font's metrics. You probably need either the font's x-height, or cap height value, which you can't get from GD.
Once you've got those values, then you can properly calculate the vertical offset you need to line everything up.

php how to fit a text into a box

I have the bounds of a rectangular box.
Is it possible to fit a text (with custom font) into the box while not knowing the text size.
I mean, is there a php function which sets the proper text size so that the text is fitted into the user-defined box?
I do not need text wrapping.
The only functions I found are imagettfbbox and imagettftext.
imagettfbbox does exactly the opposite(gives the bounds, provided a font size) while imagettftext is used to write text on an image, only if fontSize is known.
Are you using php gd? If so, then I would use imagettfbbox. Just define all the parameters except size. Then outside of that loop on size until it is small enough to fit in your defined space. I've done this before. It doesn't do any actual image creative in memory, so it's very fast (much faster than actually creating the image).
for($size=40;$size>5;$size--){
$sizearray=imagettfbbox ( $size , 0- , 'font.ttf' , $message );
$width=$sizearray[0] + $sizearray[4];
if($width<$threshold/*you define*/){
//you've got your $size
break;
}
}

Get the cell background color in PhpExcel

I'm using Excel5 in my project. I have already tried the following codes:
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->getARGB();
and
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFill()->getEndColor()->getARGB();
but these codes are returning wrong color. The getStartColor() always returning FFFFFFFF and FF000000 for getEndColor() instead of red.
I don't know what am missing. Can any one help me in figuring this out?
setReadDataOnly(TRUE) means read only the data from the cells, but none of the styling... and as background colours are part of the styling the reader will ignore background colours when it loads the file... if the fill style is not loaded, then the call to $objPHPExcel->getActiveSheet()->getStyle('A1')->getFill() will return default fill style and colours.
Load the file with setReadDataOnly(FALSE) and you should find it works
EDIT
This is way beyond the scope of PHPExcel.... everything is populated via DDE, including most of the styling, so the underlying fill colour is plain (as returned by the PHPExcel getFill colour call) until the external executable TOS.exe populates the data and sets the styles accordingly. Your only option here is to use COM so that the workbook is being executed in MS Excel itself.
Your second code:
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFill()->getEndColor()->getARGB();
Works , it just returns a color hex code (FF0000).
RGB = Red Blue Green = xx xx xx
FF0000 is actually RED.

save image after some data written on that image

Hi all
i am displaying an image in a div and content in another div.using jquery draggable method, i placed the content in that div on the image. Now i want to save that image with content as an image. Is it possible? please answer this as it is important
It's perfectly possible to do this, but it's not trivial and I won't post all the code necessary to do it. Instead, I'll give you some pointers:
You can't save the added text "as is" client-side. That's not possible. You could take a screenshot of it, but that's probably not what you want.
Instead, you need to save the text value and the position and size of where the text is placed relative to the image.
Use relative values, e.g. x = 0.3242, y = 0.5123, width = 0.5123, height = 0.12, where x = 0, y = 0 is the top left corner of the image and x = 1, y = 1 the bottom right corner, width and height similarily representing a fraction of the image size.
POST this information to the server and recreate the same effect by baking the text into the image using, for example, gd.
For finding the right font size to use, futz around with imagettfbbox until you have found the closest equivalent in size to the target coordinates.
Use imagettftext for writing the text into the image.

Categories