: Print Barcodes in CR80 Cards I have a barcode with a dimensions width: 162px and height: 50 px. When I print it in a A4 paper size,its dimension is 40 mm X 14 mmbut when printed in CR80
I have a barcode with a dimensions width: 162px and height: 50 px. When I print it in a A4 paper size,its dimension is 40 mm X 14 mmbut when printed in CR80 Cards(smaller paper size) it's size is 25mm X 9mm .
The barcode in the A4 paper is scanning well but barcodes in CR80 cards, doesnt. It is because the barcode size shrinks to fit the page and thus distorting the barcodes.
If and only if the barcodes is 40mm X 19mm in CR80 Cards it will be fine and be working(I assumed). So how will I know what dimensions (in px) , shall I command my printer to print to have the desired output?
More posts by @Karen819
1 Comments
Sorted by latest first Latest Oldest Best
A quick check suggests that the nominal size for some types (EAN-*) is "25.93mm in height and 37.29mm in width" and "they" suggest that you do not reduce that beyond 80% (20 x 29mm).
I didn't see anything specific to code39, but I suspect that your problem is merely that you have gone too far in reduction and the bars are too close together.
You don't mention the software you are using, but basically, place the image larger on the ID card. I have used 3of9 before and found that the height is less important than the width and bar spacing: The ones I used were probably about 3/8 inch high and 1.5 inches wide (about 9mm high x 38 mm wide).
If you have trouble fitting it with other information, place it large and crop the top. Experiment.
One more thing: code39 is a straight ASCII replacement scheme. This means that you can use a font. 12345abc becomes *12345abc* and you just set it using a 3of9 typeface like free 3of9. This makes sizing on the fly a non-issue and they can even be generated using a database report etc..
<?php
// Requires a font file on your server
$fR = 0; $fG = 0; $fB = 0;
$bR = 255; $bG = 255; $bB = 255;
$text_pad = 10;
$text = array(
array('text' => '', 'size' => 19, 'left' => $text_pad, 'width' => 1, 'height' => 1, 'font_path' => ''),
);
$text[0]['font_path'] = realpath('./images/free3of9.ttf'); //give it a path relative to the calling script
$text[0]['text'] = strtoupper('*12345 bobs your uncle 6789*'); //simpe code39: ONLY 0-9 A-Z (caps) . - *
$text[0]['size'] = 60;
$text[0]['left'] = $text_pad;
$result = barcode_getdimensions($text[0]['text'], $text[0]['size'], $text[0]['font_path']);
$text[0]['width'] = $result['width'];
$text[0]['height'] = $result['height'];
//************ end configuration vars
function barcode_getdimensions ($a_string, $a_size, $a_font) {
$tmp['width'] = 0;
$tmp['height'] = 0;
if ($a_size == 0) { return $tmp;}
$result = imageftbbox($a_size, 0, $a_font, $a_string);
$tmp['width'] = $result[2] - $result[0];
$tmp['height'] = $result[1] - $result[7];
return $tmp;
}
//output the header. Any non-image output after this point will throw errors
header("Content-type: image/png");
header('Content-Disposition: inline; filename=barcode.png');
$image = imagecreatetruecolor(($text_pad * 2) + $text[0]['width'],($text_pad * 2) + $text[0]['height']);
$textcolor = imagecolorallocate($image,$fR,$fG,$fB);
$bgcolor= imagecolorallocate($image,$bR,$bG,$bB);
imagefilledrectangle($image,0,0,($text_pad * 2) + $text[0]['width'],($text_pad * 2) + $text[0]['height'],$bgcolor);
imagettftext($image, $text[0]['size'], 0, $text_pad, $text_pad + $text[0]['height'], $textcolor, $text[0]['font_path'], $text[0]['text']);
imagepng($image);
imagedestroy($image); // always destroy image
?>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.