• bitcoinBitcoin(BTC)$79,949.000.11%
  • ethereumEthereum(ETH)$2,510.681.22%
  • tetherTether(USDT)$1.000.00%
  • binancecoinBNB(BNB)$753.09-2.25%
  • rippleXRP(XRP)$1.420.36%
  • usd-coinUSDC(USDC)$1.000.00%
  • solanaSolana(SOL)$106.082.27%
  • tronTRON(TRX)$0.3360730.42%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.065.05%
  • zcashZcash(ZEC)$1,230.2021.50%
  • HyperliquidHyperliquid(HYPE)$87.972.84%
  • dogecoinDogecoin(DOGE)$0.090406-0.88%
  • RainRain(RAIN)$0.016784-1.43%
  • moneroMonero(XMR)$531.00-3.22%
  • USDSUSDS(USDS)$1.000.03%
  • chainlinkChainlink(LINK)$13.118.58%
  • whitebitWhiteBIT Coin(WBT)$73.750.37%
  • leo-tokenLEO Token(LEO)$9.331.19%
  • cardanoCardano(ADA)$0.2218140.85%
  • stellarStellar(XLM)$0.1861780.63%
  • bitcoin-cashBitcoin Cash(BCH)$259.530.91%
  • daiDai(DAI)$1.000.00%
  • uniswapUniswap(UNI)$7.140.11%
  • CantonCanton(CC)$0.1107501.49%
  • Ethena USDeEthena USDe(USDE)$1.00-0.02%
  • litecoinLitecoin(LTC)$54.951.51%
  • USD1USD1(USD1)$1.000.01%
  • the-open-networkGram (prev. Toncoin)(GRAM)$1.430.05%
  • hedera-hashgraphHedera(HBAR)$0.0816700.78%
  • avalanche-2Avalanche(AVAX)$7.832.96%
  • suiSui(SUI)$0.811.24%
  • Global DollarGlobal Dollar(USDG)$1.00-0.01%
  • shiba-inuShiba Inu(SHIB)$0.000005-0.45%
  • nearNEAR Protocol(NEAR)$2.4211.70%
  • paypal-usdPayPal USD(PYUSD)$1.000.01%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • crypto-com-chainCronos(CRO)$0.0577152.11%
  • tether-goldTether Gold(XAUT)$4,419.30-0.17%
  • Circle USYCCircle USYC(USYC)$1.140.00%
  • BittensorBittensor(TAO)$269.6514.96%
  • MemeCoreMemeCore(M)$1.12-0.02%
  • Ripple USDRipple USD(RLUSD)$1.000.01%
  • okbOKB(OKB)$113.630.54%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.140.00%
  • AsterAster(ASTER)$0.78-0.62%
  • aaveAave(AAVE)$134.920.40%
  • mantleMantle(MNT)$0.602.90%
  • pax-goldPAX Gold(PAXG)$4,423.08-0.22%
  • OndoOndo(ONDO)$0.3849813.80%
  • World Liberty FinancialWorld Liberty Financial(WLFI)$0.056638-1.31%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

Designing a Schema-Guided Invoice Intelligence Pipeline with lift-pdf for Accounts-Payable Extraction, Validation, and Ledger Generation

July 3, 2026
in AI & Technology
Reading Time: 3 mins read
A A
Designing a Schema-Guided Invoice Intelligence Pipeline with lift-pdf for Accounts-Payable Extraction, Validation, and Ledger Generation
ShareShareShareShareShare

YOU MAY ALSO LIKE

H Company Releases NeoMME: A Family of 260M and 800M Single-Tower Multimodal Encoders That Drop the Vision Tower and Causal Decoder

How To Send High-Quality Images And Videos From Android To iPhone

def render_pdf(d, path):
   """Draw a realistic one-page invoice: header, meta, bill/ship, line items, totals, payment."""
   from reportlab.lib.pagesizes import LETTER
   from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
   from reportlab.lib.units import inch
   from reportlab.lib import colors
   from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer,
                                   Table, TableStyle)
   c   = compute(d)
   sym = d["currency_symbol"]
   def money(x): return f"{sym}{x:,.2f}"
   ss   = getSampleStyleSheet()
   H1   = ParagraphStyle("H1",   parent=ss["Title"],    fontSize=18, leading=22, spaceAfter=2)
   SMALL= ParagraphStyle("SM",   parent=ss["Normal"],   fontSize=8.5, textColor=colors.grey, leading=11)
   LBL  = ParagraphStyle("LBL",  parent=ss["Normal"],   fontSize=8.5, textColor=colors.HexColor("#2b3a67"),
                         spaceAfter=1, fontName="Helvetica-Bold")
   BODY = ParagraphStyle("BODY", parent=ss["Normal"],   fontSize=9.5, leading=13)
   RIGHT= ParagraphStyle("R",    parent=ss["Normal"],   fontSize=16, leading=18, alignment=2,
                         textColor=colors.HexColor("#2b3a67"), fontName="Helvetica-Bold")
   story = []
  
   head = Table([[
       [Paragraph(d["vendor_name"], H1), Paragraph(d["vendor_address"], SMALL)],
       [Paragraph("INVOICE", RIGHT),
        Paragraph(f"{d['invoice_number']}", ParagraphStyle('n', parent=SMALL, alignment=2, fontSize=9.5))],
   ]], colWidths=[4.2 * inch, 2.8 * inch])
   head.setStyle(TableStyle([("VALIGN", (0, 0), (-1, -1), "TOP")]))
   story += [head, Spacer(1, 10)]
  
   meta_rows = [["Invoice date", d["invoice_date"], "Due date", d["due_date"]]]
   if d.get("po_number"):
       meta_rows.append(["PO number", d["po_number"], "Currency", d["currency_code"]])
   else:
       meta_rows.append(["Currency", d["currency_code"], "", ""])
   meta = Table(meta_rows, colWidths=[1.3 * inch, 2.2 * inch, 1.3 * inch, 2.2 * inch])
   meta.setStyle(TableStyle([
       ("FONTSIZE", (0, 0), (-1, -1), 9),
       ("TEXTCOLOR", (0, 0), (0, -1), colors.HexColor("#2b3a67")),
       ("TEXTCOLOR", (2, 0), (2, -1), colors.HexColor("#2b3a67")),
       ("FONTNAME", (0, 0), (0, -1), "Helvetica-Bold"),
       ("FONTNAME", (2, 0), (2, -1), "Helvetica-Bold"),
       ("BOTTOMPADDING", (0, 0), (-1, -1), 3), ("TOPPADDING", (0, 0), (-1, -1), 3)]))
   story += [meta, Spacer(1, 12)]
  
   bill = [Paragraph("BILL TO", LBL), Paragraph(d["bill_to_name"], BODY),
           Paragraph(d["bill_to_address"], SMALL)]
   if d.get("ship_to_name"):
       ship = [Paragraph("SHIP TO", LBL), Paragraph(d["ship_to_name"], BODY),
               Paragraph(d["ship_to_address"], SMALL)]
   else:
       ship = [Paragraph("SHIP TO", LBL), Paragraph("Same as billing address", SMALL)]
   parties = Table([[bill, ship]], colWidths=[3.5 * inch, 3.5 * inch])
   parties.setStyle(TableStyle([("VALIGN", (0, 0), (-1, -1), "TOP"),
                                ("LEFTPADDING", (0, 0), (-1, -1), 0)]))
   story += [parties, Spacer(1, 14)]
  
   rows = [["Description", "Qty", "Unit price", "Amount"]]
   for (desc, q, up, t) in c["items"]:
       rows.append([desc, str(q), money(up), money(t)])
   items_tbl = Table(rows, colWidths=[3.5 * inch, 0.7 * inch, 1.4 * inch, 1.4 * inch])
   items_tbl.setStyle(TableStyle([
       ("BACKGROUND", (0, 0), (-1, 0), colors.HexColor("#2b3a67")),
       ("TEXTCOLOR", (0, 0), (-1, 0), colors.white),
       ("FONTSIZE", (0, 0), (-1, -1), 9.5),
       ("ALIGN", (1, 0), (-1, -1), "RIGHT"),
       ("GRID", (0, 0), (-1, -1), 0.4, colors.HexColor("#cdd3e6")),
       ("ROWBACKGROUNDS", (0, 1), (-1, -1), [colors.white, colors.HexColor("#eef1f8")]),
       ("LEFTPADDING", (0, 0), (-1, -1), 8), ("TOPPADDING", (0, 0), (-1, -1), 5),
       ("BOTTOMPADDING", (0, 0), (-1, -1), 5)]))
   story += [items_tbl, Spacer(1, 10)]
  
   tot_rows = [["Subtotal", money(c["subtotal"])]]
   if c["discount"]:
       tot_rows.append(["Discount", "-" + money(c["discount"])])
   tot_rows.append([f"Tax ({d['tax_rate']*100:.1f}%)", money(c["tax"])])
   tot_rows.append(["TOTAL", money(c["total"])])
   totals = Table(tot_rows, colWidths=[1.6 * inch, 1.4 * inch], hAlign="RIGHT")
   totals.setStyle(TableStyle([
       ("FONTSIZE", (0, 0), (-1, -1), 10),
       ("ALIGN", (0, 0), (-1, -1), "RIGHT"),
       ("LINEABOVE", (0, -1), (-1, -1), 1.0, colors.HexColor("#2b3a67")),
       ("FONTNAME", (0, -1), (-1, -1), "Helvetica-Bold"),
       ("TEXTCOLOR", (0, -1), (-1, -1), colors.HexColor("#2b3a67")),
       ("TOPPADDING", (0, 0), (-1, -1), 3), ("BOTTOMPADDING", (0, 0), (-1, -1), 3)]))
   story += [totals, Spacer(1, 8)]
  
   pay_rows = [["Amount paid", money(c["amount_paid"])],
               ["Balance due", money(c["balance"])]]
   pay = Table(pay_rows, colWidths=[1.6 * inch, 1.4 * inch], hAlign="RIGHT")
   due_color = colors.HexColor("#1b7a3d") if c["is_paid"] else colors.HexColor("#7a2e2e")
   pay.setStyle(TableStyle([
       ("FONTSIZE", (0, 0), (-1, -1), 10),
       ("ALIGN", (0, 0), (-1, -1), "RIGHT"),
       ("FONTNAME", (0, 1), (-1, 1), "Helvetica-Bold"),
       ("TEXTCOLOR", (0, 1), (-1, 1), due_color),
       ("TOPPADDING", (0, 0), (-1, -1), 2), ("BOTTOMPADDING", (0, 0), (-1, -1), 2)]))
   status = "PAID IN FULL" if c["is_paid"] else "BALANCE DUE"
   story += [pay, Spacer(1, 6),
             Paragraph(f"Status: {status}", BODY), Spacer(1, 16),
             Paragraph("Notes", LBL), Paragraph(d["notes"], BODY)]
   SimpleDocTemplate(path, pagesize=LETTER,
                     topMargin=0.7 * inch, bottomMargin=0.7 * inch,
                     leftMargin=0.8 * inch, rightMargin=0.8 * inch).build(story)
print("STEP 3/7 · Generating synthetic invoice PDFs…")
CORPUS = []
for i, d in enumerate(DOCS):
   path = f"/content/invoice_{i}.pdf" if os.path.isdir("/content") else f"invoice_{i}.pdf"
   render_pdf(d, path)
   CORPUS.append((d, ground_truth(d), path))
   print(f"     ✓ {os.path.basename(path)}  —  {d['vendor_name']} → {d['bill_to_name']}")
print()
if SHOW_FIRST_PAGE:
   try:
       import pypdfium2 as pdfium, matplotlib.pyplot as plt
       pg  = pdfium.PdfDocument(CORPUS[0][2])[0]
       img = pg.render(scale=2.0).to_pil()
       plt.figure(figsize=(6.4, 8.3)); plt.imshow(img); plt.axis("off")
       plt.title("What lift reads — page 1 of invoice_0.pdf", fontsize=10); plt.show()
   except Exception as e:
       print("     page preview skipped:", e, "\n")

Credit: Source link

ShareTweetSendSharePin

Related Posts

H Company Releases NeoMME: A Family of 260M and 800M Single-Tower Multimodal Encoders That Drop the Vision Tower and Causal Decoder
AI & Technology

H Company Releases NeoMME: A Family of 260M and 800M Single-Tower Multimodal Encoders That Drop the Vision Tower and Causal Decoder

September 6, 2026
How To Send High-Quality Images And Videos From Android To iPhone
AI & Technology

How To Send High-Quality Images And Videos From Android To iPhone

September 6, 2026
What Is Vibe Coding And Why Does It Get So Much Hate?
AI & Technology

What Is Vibe Coding And Why Does It Get So Much Hate?

September 6, 2026
My Content Tracker Idea Became a Real App – Unite.AI
AI & Technology

My Content Tracker Idea Became a Real App – Unite.AI

September 6, 2026
Next Post
Taylor Swift and Travis Kelce's wedding day arrives with Madison Square Garden under tight security – CBS News

Taylor Swift and Travis Kelce's wedding day arrives with Madison Square Garden under tight security - CBS News

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
Fallen utility pole sparks blaze and burns seven cars

Fallen utility pole sparks blaze and burns seven cars

September 3, 2026
Modding Platform Nexus Mods Now Owns SteamDB

Modding Platform Nexus Mods Now Owns SteamDB

September 2, 2026
Tropical Storm Bertha makes landfall

Tropical Storm Bertha makes landfall

September 6, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!