...
Code Block | ||
---|---|---|
| ||
# importing modules
import argparse
import json
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen import canvas
parser=argparse.ArgumentParser()
parser.add_argument("--args", help="JSON string of arguments")
parser.add_argument("--scriptExecutionID", help="scriptExecutionIDn")
parser.add_argument("--files", help="files")
cmdArgs=parser.parse_args()
scriptExecutionID = cmdArgs.scriptExecutionID
argJson = json.loads(cmdArgs.args)
recipient = argJson["responses"][0]["values"][0]
# initializing variables with values
fileName = '/app/dependencies/output/bill_' + scriptExecutionID + '.pdf'
documentTitle = 'Rechnung'
title = 'Max Mustermann'
# creating a pdf object
pdf = canvas.Canvas(fileName)
# setting the page size
pdf.setPageSize((222,500))
# setting the title of the document
pdf.setTitle(documentTitle)
# registering a external font in python
pdfmetrics.registerFont(TTFont('Regular', '/app/dependencies/MerchantCopy.ttf'))
pdfmetrics.registerFont(TTFont('Wide', '/app/dependencies/MerchantCopyWide.ttf'))
# creating the title by setting it's font
# and putting it on the canvas
pdf.setFont('Wide', 14)
pdf.drawCentredString(110, 460, 'Max Mustermann')
pdf.setFont("Regular", 14)
pdf.drawCentredString(110, 450, 'Musterstrasse 1')
pdf.drawCentredString(110, 440, 'AT-1020 Wien')
pdf.drawCentredString(110, 430, 'MAIL: max.mustermann@demo.at')
pdf.drawCentredString(110, 420, 'TEL: 0664-12345678')
pdf.drawCentredString(110, 410, ' ')
pdf.drawCentredString(110, 400, ' ')
pdf.drawCentredString(110, 390, recipient + ' ')
pdf.drawCentredString(110, 380, 'ABC 12345 ')
pdf.drawCentredString(110, 370, 'AT-1010 Wien ')
pdf.drawCentredString(110, 360, ' ')
pdf.drawCentredString(110, 350, ' ')
pdf.drawCentredString(110, 340, ' R E C H N U N G ')
pdf.drawCentredString(110, 330, ' ')
pdf.drawCentredString(110, 320, '--------------------------------------')
pdf.drawCentredString(110, 310, 'Re-Nr: 22-004 Datum: 31.11.2022')
pdf.drawCentredString(110, 300, ' ')
pdf.drawCentredString(110, 290, 'Anbindung Webshop/FIBU B 800.00')
pdf.drawCentredString(110, 280, ' 8 x 100.00 ')
pdf.drawCentredString(110, 270, 'Office365 Setup/Interface B 1700.00')
pdf.drawCentredString(110, 260, ' 17 x 100.00 ')
pdf.drawCentredString(110, 250, ' ')
pdf.drawCentredString(110, 240, '--------------------------------------')
pdf.drawCentredString(110, 230, 'Summe EUR 2500.00')
pdf.drawCentredString(110, 220, '======================================')
pdf.drawCentredString(110, 210, 'Zahlbar innerhalb 14 Tagen ')
pdf.drawCentredString(110, 200, ' ')
pdf.drawCentredString(110, 190, 'IBAN AT1234123412341234 ')
pdf.drawCentredString(110, 180, 'BIC ABCDEFGHIJK ')
pdf.drawCentredString(110, 170, ' ')
pdf.drawCentredString(110, 160, 'Leistungszeitraum: ')
pdf.drawCentredString(110, 150, '01.09.2022 - 21.11.2022 ')
pdf.drawCentredString(110, 140, ' ')
pdf.drawCentredString(110, 130, 'Umsatzsteuerfrei aufgrund ')
pdf.drawCentredString(110, 120, 'der Kleinunternehmerregelung ')
pdf.drawCentredString(110, 110, ' ')
pdf.drawCentredString(110, 100, '--------------------------------------')
pdf.drawCentredString(110, 90, '')
pdf.drawCentredString(110, 80, 'Vielen Dank fuer Ihren Auftrag!')
pdf.drawCentredString(110, 30, '')
pdf.drawCentredString(110, 20, '--------------------------------------')
pdf.save() |
Viewing Output in VSCode
Currently there is no separated output folder to transfer files between the scripting container and vscode. As an workaround you can save files in ‘/app/dependencies’
The following mounts are in place
Code Block |
---|
volumeMounts:
- mountPath: /app/scripts # -> Inside the scripting container
name: portrait-config-pvc
subPath: scripting/pythonScripts # -> Inside the vscode container
- mountPath: /app/setupScripts
name: portrait-config-pvc
subPath: scripting/pythonSetupScripts
- mountPath: /app/dependencies
name: portrait-config-pvc
subPath: scripting/pythonDependencies |