How to create a barcode using pylatex

113 Views Asked by At

I am writing a python script to generate a bunch of pdfs that display information from a database. I want to generate a barcode on each pdf page but I am unsure how to do it using the pylatex library.

For example, in latex you can create a barcode like so:

\begin{pspicture}(1.5,3)
\psbarcode{00700}{}{ean5}
\end{pspicture}

Currently each pdf document is being generated following a template similar to this:

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")
      page.append("\nCITY, POSTAL CODE")

   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)

How would I go about adding a barcode to this document?

0

There are 0 best solutions below