Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, I believe I found a solution that applies not to every browser and printer combination, but it suits me nicely.</p> <p>I am using the barodegen php library found at <a href="https://www.barcodephp.com/en" rel="nofollow">barcodegen</a> because it is the only one allowing me to specify a subset for some characters and another one for others.</p> <p>In my specific problem, I can do this:</p> <pre><code>$setB = '%'.substr($vars-&gt;code, 0, 7); $setC = substr($vars-&gt;code, 7); $code_array = array(array(CODE128_B, $setB), array(CODE128_C, $setC)); </code></pre> <p>And then parse $code_array into a barcode.</p> <p>Now, the other problem is also simply solved by setting the point per inch of the generated barcode image. This is called, wrongly I think, DPI. Correct me if I'm mistaken, but DPI is a harware characteristic of a printer. You can't change that. PPI on the other hand, you can change.</p> <p>In my problem I had a 244px wide image, and I needed it to print in more than 95mm. barcodegen allows you to do this by calling</p> <pre><code>$drawing-&gt;setDPI(64); // I do think they should rename this to setPPI </code></pre> <p>Now, after you have a 224px image with 64ppi, all you need to do is show it in an img tag like this:</p> <pre><code>&lt;img style="width: 96.8375mm;" src="interlink_code128_barcode.php?code='.$code128.'" border="0"&gt; </code></pre> <p>the 96.8375mm is obtained by solving the simple equation, if the image contains 64 pixels in one inch, how much inches will occupy 244 pixels? And then you transform inches to mm</p> <p>I haven't got confirmation that the barcodes can be read at high speeds, but I do see the printouts looking sharp! :D</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload