[reportlab-users] Need help creating fillable forms with reportlab
Arturo López
lopalcar at gmail.com
Fri May 10 04:35:37 EDT 2019
Hi!
I need to create a pdf where user fill some fields but other fields are calculated according to the values the user introduces, for example, the user set the number of beers and price for each and total price is calculated automatically in the pdf.
I need this to be calculated after the pdf is created of course, because it needs user input, in reportlab I create the empty pdf with this instructions in the fields.
Attached simple concept code to sum two numbers.
Hope someone have an answer and if it's possible "it is using adobe acrobat" so hoping this functionality is also integrated in reportlab... acroForms have some "name" and "value" fields, but I don't know how to access them
Here is the reportlab documentation I followed: https://www.reportlab.com/docs/reportlab-userguide.pdf <https://www.reportlab.com/docs/reportlab-userguide.pdf>
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfform
from reportlab.lib.colors import magenta, pink, blue, green, white
def GenerarFactura():
c = canvas.Canvas('simple_form.pdf')
c.setLineWidth(.5)
c.setFont('Helvetica', 12)
form = c.acroForm
c.drawString(70, 740, "Num 1: ")
form.textfield(x=140, y=725, borderStyle='underlined',
width=150,fillColor=white)
c.drawString(70, 700, "Num 2: ")
form.textfield(x=140, y=685, borderStyle='underlined',
width=150,fillColor=white)
c.drawString(70, 660, "Sum 1+2: ")
form.textfield(x=140, y=645, borderStyle='underlined',
width=150,fillColor=white)
c.save()
if __name__ == '__main__':
GenerarFactura()
Here is the question posted in stackoverflow: https://stackoverflow.com/questions/56057416/create-fillable-pdf-and-sum-fillable-fields-content-with-reportlab <https://stackoverflow.com/questions/56057416/create-fillable-pdf-and-sum-fillable-fields-content-with-reportlab>
First time using mailing list, hope it’s right like this, thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20190510/6645eca1/attachment-0001.html>
More information about the reportlab-users
mailing list