1

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?

NicLovin
  • 317
  • 3
  • 20
  • @KJ EAN5 would work for me, how would I set the font for the encoded string in pylatex? – NicLovin Aug 27 '21 at 19:51
  • @KJ Yes I think the solution I'm looking for is how to use \psbarcode with```pylatex```, I want to use a package to build the barcode – NicLovin Aug 27 '21 at 20:23

0 Answers0