generate_sources.py
"""SYNTHETIC PDFs generated locally. No external files or network."""
from pathlib import Path
from reportlab.pdfgen import canvas
from reportlab.lib import colors
from reportlab.platypus import Table,TableStyle
ROOT=Path(__file__).resolve().parent
INVOICE_ROWS=[
['1','Workflow diagnosis','2','25.00','50.00'],
['2','CRM repair sprint','3','80.00','240.00'],
['3','Synthetic fixture pack','1','45.50','45.50'],
['4','Regression checks','4','30.00','120.00'],
['5','=DEMO() text label','1','15.00','15.00'],
['6','Handoff walkthrough','2','40.00','80.00']]
STATEMENT_ROWS=[
['2026-11-01','TX001','Synthetic deposit','','1200.00','2200.00'],
['2026-11-02','TX002','Office supplies','85.50','','2114.50'],
['2026-11-03','TX003','Service charge','20.00','','2094.50'],
['2026-11-04','TX004','Ambiguous source glyph','O5.00','','2089.50'],
['2026-11-05','TX005','Synthetic refund','','200.00','2289.50'],
['2026-11-06','TX006','Equipment','125.00','','2164.50'],
['2026-11-07','TX007','Stationery','44.25','','2120.25'],
['2026-11-08','TX008','Synthetic rebate','','50.00','2170.25']]
HEADERS={'invoice':['Line','Description','Qty','Unit price','Amount'],
'statement':['Date','Reference','Description','Debit','Credit','Balance']}
def generate(output=None,invoice_total='550.50'):
output=Path(output or ROOT/'sources'); output.mkdir(parents=True,exist_ok=True)
for kind,doc_id,rows,widths,chunk in [
('invoice','SYN-INV-1001',INVOICE_ROWS,[35,260,45,100,100],3),
('statement','SYN-ST-1001',STATEMENT_ROWS,[70,65,180,75,75,75],4)]:
c=canvas.Canvas(str(output/(kind+'.pdf')),pagesize=(612,792),invariant=1)
c.setTitle('SYNTHETIC '+kind+' fixture'); c.setAuthor('Synthetic portfolio demo')
for p in range(2):
c.setFillColor(colors.HexColor('#12243a')); c.rect(0,682,612,110,fill=1,stroke=0)
c.setFillColor(colors.white); c.setFont('Helvetica-Bold',22)
c.drawString(36,747,'INVOICE' if kind=='invoice' else 'ACCOUNT STATEMENT')
c.setFont('Helvetica',10); c.drawString(36,724,'SYNTHETIC DEMO | Fictitious business and transactions')
c.drawString(36,705,('Invoice' if kind=='invoice' else 'Statement')+' No: '+doc_id)
c.setFillColor(colors.HexColor('#24364c')); c.drawString(36,653,'SampleWorks Studio | example.test | USD')
c.drawString(36,635,'Bill to: Synthetic Client' if kind=='invoice' else 'Account: SYNTHETIC-0001 | Opening balance: 1000.00')
page_rows=rows[p*chunk:(p+1)*chunk]
t=Table([HEADERS[kind]]+page_rows,colWidths=widths,rowHeights=[28]+[36]*len(page_rows))
t.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,0),colors.HexColor('#e7edf4')),
('FONTNAME',(0,0),(-1,0),'Helvetica-Bold'),('FONTNAME',(0,1),(-1,-1),'Helvetica'),
('TEXTCOLOR',(0,0),(-1,-1),colors.HexColor('#15283e')),('FONTSIZE',(0,0),(-1,-1),9),
('VALIGN',(0,0),(-1,-1),'MIDDLE'),('GRID',(0,0),(-1,-1),0.5,colors.HexColor('#92a4b7')),
('ALIGN',(2 if kind=='invoice' else 3,0),(-1,-1),'RIGHT'),('LEFTPADDING',(0,0),(-1,-1),7),('RIGHTPADDING',(0,0),(-1,-1),7)]))
_,th=t.wrap(540,600); t.drawOn(c,36,602-th); y=572-th
footer=['Continued on next page.'] if p==0 else (['Line items: 6','Total quantity: 13','Subtotal USD: '+invoice_total] if kind=='invoice' else ['Transactions: 8','Total debits: 279.75','Total credits: 1450.00','Closing balance: 2170.25'])
for line in footer: c.setFont('Helvetica-Bold',10); c.drawString(36,y,line); y-=20
c.setFont('Helvetica',9); c.setFillColor(colors.HexColor('#51657c')); c.drawString(36,70,'Synthetic layout fixture. No real client data. No financial advice.')
if kind=='statement': c.drawString(36,54,'One amount deliberately contains the letter O; manual review is required.')
c.drawRightString(576,30,f'Page {p+1} of 2'); c.showPage()
c.save()
return output
if __name__=='__main__':
generate(); print('Generated 2 synthetic PDFs / 4 pages in sources/')