How can I adjust the top and bottom borders of a barcode created with python-barcode?

138 Views Asked by At

I'm using barcode.Code39 and barcode.writer.ImageWriter from the python-barcode library (version 0.15.1) to create a simple barcode and dump it to a PNG. I was able to control the left and right borders using the quiet_zone option and remove the text using the write_text option.

However, the ImageWriter also adds top and bottom borders to the PNG created by the barcode package itself. I want to fit the image into a small space in a spreadsheet-type report. Is it possible to control these directly, rather than post-processing the PNG to remove them?

I couldn't find any related options by reading the package source code.

1

There are 1 best solutions below

0
OptiAndrew On

python-barcode has options margin_top and margin_bottom that can control the margins.