Title above image, manifest table on first page
Page 1 (Manifest): - Header with title, source, date, count - Table listing all products: #, name, SKU, price, stock qty Product pages: - Title (bold, top) - Product image (bordered, centered) - Stock + price - UPC-A barcode (bordered, centered) - SKU / UPC text
This commit is contained in:
41
disco.py
41
disco.py
@@ -265,13 +265,34 @@ def generate_catalog_pdf(products: list[dict]) -> Path | None:
|
||||
r"\pagestyle{empty}",
|
||||
r"\begin{document}",
|
||||
"",
|
||||
# Title page
|
||||
# Manifest page
|
||||
r"\begin{center}",
|
||||
r"{\Huge\bfseries Pokemon TCG Product Catalog}\\[0.5cm]",
|
||||
r"{\Large Dollar General}\\[0.3cm]",
|
||||
r"{\Huge\bfseries Pokemon TCG Product Catalog}\\[0.4cm]",
|
||||
r"{\Large Dollar General}\\[0.2cm]",
|
||||
r"{\large Generated: " + timestamp_label + r"}\\[0.2cm]",
|
||||
r"{\large " + str(len(products)) + r" Cards \& Tins}",
|
||||
r"\end{center}",
|
||||
r"\vspace{0.8cm}",
|
||||
r"\begin{tabular}{r l l r r}",
|
||||
r"\hline",
|
||||
r"\textbf{\#} & \textbf{Product} & \textbf{SKU} & \textbf{Price} & \textbf{Stock} \\",
|
||||
r"\hline",
|
||||
]
|
||||
for i, prod in enumerate(products, 1):
|
||||
safe = (
|
||||
prod["title"][:50]
|
||||
.replace("&", r"\&").replace("%", r"\%").replace("$", r"\$")
|
||||
.replace("#", r"\#").replace("_", r"\_").replace("é", r"\'e")
|
||||
)
|
||||
price = prod["price"].replace("$", r"\$")
|
||||
qty = prod.get("quantity", 0)
|
||||
stock_short = str(qty) if qty else "---"
|
||||
latex_lines.append(
|
||||
f"{i} & {safe} & \\texttt{{{prod['sku']}}} & {price} & {stock_short} \\\\"
|
||||
)
|
||||
latex_lines += [
|
||||
r"\hline",
|
||||
r"\end{tabular}",
|
||||
r"\newpage",
|
||||
"",
|
||||
]
|
||||
@@ -311,18 +332,18 @@ def generate_catalog_pdf(products: list[dict]) -> Path | None:
|
||||
abs_bc = str(bc_path.resolve()) if bc_path else None
|
||||
|
||||
latex_lines += [
|
||||
# Name — bold, large, above the image
|
||||
r"{\Large\bfseries " + safe_title + r"}",
|
||||
"",
|
||||
r"\vspace{0.3cm}",
|
||||
"",
|
||||
r"\begin{center}",
|
||||
# Product image — large, centered, with border
|
||||
r"\fbox{\includegraphics[width=0.7\textwidth,height=0.45\textheight,keepaspectratio]{"
|
||||
r"\fbox{\includegraphics[width=0.7\textwidth,height=0.42\textheight,keepaspectratio]{"
|
||||
+ abs_img
|
||||
+ r"}}",
|
||||
r"\end{center}",
|
||||
r"\vspace{0.4cm}",
|
||||
"",
|
||||
# Name — bold, large
|
||||
r"{\Large\bfseries " + safe_title + r"}",
|
||||
"",
|
||||
r"\vspace{0.15cm}",
|
||||
r"\vspace{0.3cm}",
|
||||
"",
|
||||
# Stock and price
|
||||
r"{\large " + safe_stock + r" \hfill " + safe_price + r"}",
|
||||
|
||||
Reference in New Issue
Block a user