georgelvc Posted July 13, 2017 Share Posted July 13, 2017 function draw($str,$checksum=false){ global $unit,$x,$Code39,$height,$bw; $str=strtoupper($str); if ($checksum) { $str=$str.checksum($str); } $str='*'.$str.'*'; $long=(strlen($str)+100)*100; $width=$bw*$long; $text=str_split($str); $img=''; $img.= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"[url=http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\]http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";[/url] $img.= "<svg width='$width$unit' height='$height$unit' version='1.1' xmlns=' [url=http://www.w3.org/2000/svg] foreach($text as $char){ $img.=drawsymbol($char); } $img.='</svg>'; return $img; } function drawsymbol($char){ global $unit,$Code39,$x,$y,$dx,$bw,$fs,$dx,$yt,$bl; $x+=$bw; $img=''; $img.= '<desc>'.htmlspecialchars($char)."</desc>\n"; $xt=$x+$dx; $img.= "<text x='$xt$unit' y='$yt$unit' font-family='Arial' font-size='$fs'>$char</text>\n"; $val =str_split($Code39[$char]); $len=9; for ($i=0; $i<$len; $i++){ $num=(int)$val[$i]; $w=$bw*$num; if(!($i % 2)){ $img.= "<rect x='$x$unit' y='$y$unit' width='$w$unit' height='$bl$unit' fill='black' stroke-width='0' />\n"; } $x += $w; } return $img; } ?> <!DOCTYPE html> <html> <head> <title></title> </head> <body> <form method="GET" action="Code39.php"> </form> </body> </html> <?php ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); $mcode=1000001; $count=0; while ($count<=20){ $code = isset($_GET['code']) ? $_GET['code'] :$mcode ; $barcode = draw($code); echo "<div style=\"float:left;\">"; echo $mcode."<br>"; echo $barcode."<br>"; echo "</div>"; $count++; $mcode++; } ?> Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted July 13, 2017 Share Posted July 13, 2017 Read the forum rules, especially the parts about asking proper questions and formatting code. Quote Link to comment Share on other sites More sharing options...
georgelvc Posted July 13, 2017 Author Share Posted July 13, 2017 (edited) Ok thank you for your answer. How can i delete this topic? Edited July 13, 2017 by georgelvc Quote Link to comment Share on other sites More sharing options...
georgelvc Posted July 13, 2017 Author Share Posted July 13, 2017 (edited) May God bless you. Edited July 13, 2017 by georgelvc Quote Link to comment Share on other sites More sharing options...
gizmola Posted July 13, 2017 Share Posted July 13, 2017 This is really an html question, is it not? All that code, and your question boils down to this section: echo "<div style=\"float:left;\">"; echo $mcode."<br>"; echo $barcode."<br>"; echo "</div>"; See those tags? You know what they do, don't you? If you take those out, what do you think will happen? Try this perhaps? Quote Link to comment Share on other sites More sharing options...
georgelvc Posted July 13, 2017 Author Share Posted July 13, 2017 @gizmola. After i delete the <br> tags, it still the same. Would you mind if i post the full code so that you can run and test it. But this site can approve it or not because of the forum rules. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted July 13, 2017 Share Posted July 13, 2017 (edited) The reason why I pointed you to the forum guidelines was to a) make you use code tags and b) see an honest debugging attempt from you. This "Here's a wall of code I copied and pasted from the Internet, now fix it for me" doesn't work. He can help you with specific issues, but we aren't going to do your job. You've posted a screen shot. Have you also looked at it? You keep increasing the left margin, which will obviously defeat any alignment attempts. If you look at the page source (or just the scroll bar of your browser), you'll also see that the calculated width of a single image is gigantic. No screen is big enough to display those images next to each other. Again, those are basic debugging steps which everybody can do. Yet they make a big difference, because they show that you actually care about the problem, and they allow us to have a proper discussion. Edited July 13, 2017 by Jacques1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.