<div dir="ltr">Il giorno 11 novembre 2013 18:19, Riccardo Brazzale <span dir="ltr"><<a href="mailto:riccardo.brazzale@gmail.com" target="_blank">riccardo.brazzale@gmail.com</a>></span> ha scritto:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Ho creato un piccolo report con Reportlab nel quale devo inserire un barcode di tipo 128</div>
<div><br></div><div>Funziona tutto ma non riesco a regolare le dimensioni del barcode (altezza e larghezza).</div>
<div><br></div><div>Qualche idea?</div></div></blockquote><div><br></div><div>Non avendo idea di cosa fosse Reportlab l'ho cercato su google e ho trovato questo:</div><div><a href="http://fossies.org/dox/reportlab-2.7/classreportlab_1_1graphics_1_1barcode_1_1code128_1_1Code128.html" target="_blank">http://fossies.org/dox/reportlab-2.7/classreportlab_1_1graphics_1_1barcode_1_1code128_1_1Code128.html</a><br>
</div><div>Puoi vedere che Code128 ha, fra gli attributi, barHeight e barWidth.</div><div><br></div><div>Ho provato a modificare lo script che trovi qui: <a href="http://www.blog.pythonlibrary.org/2013/03/25/reportlab-how-to-create-barcodes-in-your-pdfs-with-python/" target="_blank">http://www.blog.pythonlibrary.org/2013/03/25/reportlab-how-to-create-barcodes-in-your-pdfs-with-python/</a></div>
<div><br></div><div>Con questo codice:</div><div><div><font face="courier new, monospace"> from reportlab.pdfgen.canvas import Canvas</font></div><div><font face="courier new, monospace"> from reportlab.lib.pagesizes import letter</font></div>
<div><font face="courier new, monospace"> from reportlab.graphics.barcode import code128</font></div><div><font face="courier new, monospace"> from reportlab.lib.units import mm</font></div><div><font face="courier new, monospace"><br>
</font></div><div><br></div><div><div><font face="courier new, monospace"> c = Canvas("barcodes.pdf", pagesize=letter)</font></div><div><font face="courier new, monospace"> barcode_value = "1234567890"</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> barcode = code128.Code128(barcode_value)</font></div><div><font face="courier new, monospace"> barcode.barHeight = 100</font></div>
<div><font face="courier new, monospace"> barcode.barWidth = 0.2*mm</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> # le coordinate partono apparentemente da bottom left (↑→)</font></div>
<div><font face="courier new, monospace"> x = 50</font></div><div><font face="courier new, monospace"> y = letter[1] - barcode.barHeight - 50</font></div><div><font face="courier new, monospace"> barcode.drawOn(c, x, y)</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> c.save()</font></div></div></div><div><br></div><div>Si ottiene questo pdf:</div><div><font face="courier new, monospace"> <a href="http://docdroid.net/611s" target="_blank">http://docdroid.net/611s</a></font><br>
</div><div><br></div><div>Mentre provando a cambiare altezza e larghezza delle barre:</div><div><div><font face="courier new, monospace"> barcode.barHeight = 100<br></font></div><div><font face="courier new, monospace"> barcode.barWidth = 1*mm</font></div>
<div><font face="courier new, monospace"><br></font></div><div>si ottiene questo pdf:</div><div> <font face="courier new, monospace"><a href="http://docdroid.net/611x" target="_blank">http://docdroid.net/611x</a></font><br>
</div></div>
<div><br></div><div><br></div><div>Does it make sense?<br></div><div><br></div><div>Saluti,</div><div>Nadir</div></div>
</div></div>