Ejemplo n.º 1
0
# Must be UTF-16 with correct BOM and MD-DOS line endings
importFile = open("importFile", mode="w", newline="\r\n", encoding='utf-16')

# PaperCut needs this header line in this format
importFile.write(
    "CardNumber,BatchID,ValueNumber,Value,ExpDate,ExpDateDisplay\n")

# Modify to as needed
expDate = date.today() + timedelta(
    days=14)  # expire all the cards -- default to 14 days
displayExpDate = expDate.strftime("%x")
isoExpDate = expDate.isoformat()

displayValue = locale.currency(cardValue, grouping=True)

for cardNumber in sample(range(100000000), numberOfCards):

    importFile.write(
        f'"{batchID}-{cardNumber:09d}","{batchID}","{cardValue}","{displayValue}","{isoExpDate}","{displayExpDate}"\n'
    )

    pdf.start_keeptogether()
    # Make sure cards are not split across page boundaries
    pdf.h1("PaperCut NG Top Up Card")
    pdf.p(template.format(displayValue, displayExpDate, batchID, cardNumber))
    pdf.end_keeptogether()

pdf.generate()
importFile.close()
Ejemplo n.º 2
0
pdf = PDFDocument("printFile.pdf")

pdf.init_report()

# Must be UTF-16 with correct BOM and MD-DOS line endings
importFile = open("importFile", mode="w", newline="\r\n", encoding='utf-16')

# PaperCut needs this header line in this format
importFile.write("CardNumber,BatchID,ValueNumber,Value,ExpDate,ExpDateDisplay\n")

# Modify to as needed
expDate = date.today() + timedelta(days=14) # expire all the cards -- default to 14 days
displayExpDate = expDate.strftime("%x")
isoExpDate = expDate.isoformat()

displayValue = locale.currency( cardValue, grouping=True )

for cardNumber in sample(range(100000000), numberOfCards):

    importFile.write(
        f'"{batchID}-{cardNumber:09d}","{batchID}","{cardValue}","{displayValue}","{isoExpDate}","{displayExpDate}"\n')

    pdf.start_keeptogether(); # Make sure cards are not split across page boundaries
    pdf.h1("PaperCut NG Top Up Card")
    pdf.p(template.format(displayValue,  displayExpDate,  batchID, cardNumber))
    pdf.end_keeptogether()

pdf.generate()
importFile.close()