1

我正在编写一个 python 脚本来生成一堆显示来自数据库的信息的 pdf。我想在每个 pdf 页面上生成一个条形码,但我不确定如何使用该pylatex库来执行此操作。

例如,latex您可以像这样创建条形码:

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

目前,每个 pdf 文档都是按照类似于以下的模板生成的:

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)

我将如何在此文档中添加条形码?

4

0 回答 0