I'm trying to create a python program that creates numerous pdfs each containing a unique barcode using pylatex
. Is there a simple way to do this?
Here is an example of how the latex document is being generated using pylatex
:
with doc.create(MiniPage(width=r"\textwidth")) as page:
with page.create(TextBlock(100, 0, 0)):
page.append("**** Ten Thousand Dollars")
with page.create(TextBlock(100, 0, 30)):
page.append("COMPANY NAME")
page.append("\nSTREET, ADDRESS")
with page.create(TextBlock(100, 150, 40)):
page.append()
with page.create(TextBlock(80, 150, 0)):
page.append("DATE")
page.append(MediumText(bold("test")))
page.append(HorizontalSpace("10mm"))
with page.create(TextBlock(70, 150, 30)):
page.append(MediumText(bold("$***** 10,000.00")))
page.append(VerticalSpace("100mm"))
doc.generate_pdf(doc_location, clean_tex=False)
I would like to figure out a way to append a barcode to the page.
Best Answer
The python code you included doesn't seem to produce the expected output, perhaps it is just my settings or I have not used it correctly. Regardless, please see this code which implements the
makebarcode
package and prints a barcode:This produces this broken output, I am not sure why but the code you included is not compiling properly:
I am sure you can debug why it is not working, I do not know and cannot profess to great knowledge of python, pylatex or latex as I am still learning! It produces your barcode though, you can change the string (ZDENEK WAGNER in this case which was the one from the
makebarcode
package documentation) to something random, I am sure this is trivial in python to create random or pseudorandom strings.Change the package options (makebarcode_options has been set according to the
makebarcode
package documentation on page 2, have a look and change as needed) and or package in the places I have commented using the ctan link that Willie Wong posted in the comments if you wish. Hope this helps!