Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could try reportlab as your pdf template is relatively easy. I'm not sure where you'll pull your data from and how exactly does your template looks like, but I'd written a small code to let you see or get started up. It's better if you could go through reportlab's user guide.</p> <p>You could check out html to pdf for python solution. It should be what you're looking for as well.</p> <p>Reportlab example:</p> <pre><code>import datetime from reportlab.pdfgen import canvas from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.pagesizes import A4, letter, inch, cm from reportlab.platypus import Paragraph, SimpleDocTemplate, Table, TableStyle, Spacer, KeepTogether, CondPageBreak from reportlab.lib import colors from reportlab.lib.enums import TA_JUSTIFY, TA_LEFT, TA_CENTER styles = getSampleStyleSheet() class Sales( object ): def __init__(self): self.salesname = 'Jason' self.orderqty = 1000 self.confirmqty = 900 self.shipqty = 50 jason = Sales() # get current date date = datetime.date.today() jahr = date.year monat = date.month tag = date.day story = [] # Styles styleN = styles["BodyText"] styleN.alignment = TA_LEFT styleBH = styles["Normal"] styleBH.alignment = TA_CENTER styleH = styles["Heading2"] # Static texts title = "ABC Corp" subtitle = "Daily Sales Report" # Headers hdescrpcion = Paragraph('''&lt;b&gt;SalesName&lt;/b&gt;''', styleBH) hpartida = Paragraph('''&lt;b&gt;OrderQty&lt;/b&gt;''', styleBH) hcandidad = Paragraph('''&lt;b&gt;ConfirmedQty&lt;/b&gt;''', styleBH) hprecio_unitario = Paragraph('''&lt;b&gt;ShippedQty&lt;/b&gt;''', styleBH) # Date mydate = Paragraph('''Report Date: '''+str(jahr)+'''-'''+str(monat)+'''-'''+str(tag), styleN) # 2 col data data_2col =[[subtitle,mydate]] table2 = Table(data_2col, colWidths=[5.05 * cm, 5* cm]) # 4 col data data= [[hdescrpcion, hpartida,hcandidad, hprecio_unitario], [jason.salesname, jason.orderqty, jason.confirmqty, jason.shipqty]] table = Table(data, colWidths=[2.05 * cm, 2.7 * cm, 5 * cm, 3* cm]) table.setStyle(TableStyle([ ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), ('BOX', (0,0), (-1,-1), 0.25, colors.black), ])) story.append(Paragraph(title,styleH)) story.append(Spacer(1, 12)) story.append(table2) story.append(Spacer(1, 12)) story.append(table) doc = SimpleDocTemplate('template.pdf',pagesize = A4,rightMargin=18,leftMargin=18, topMargin=18,bottomMargin=18, showBoundary=False, allowSplitting = True) doc.build(story) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload