'How to pass some variable values to RML file in Python?
Given an RML template, used to generate PDF file in python, how can one use variables declared in a Python script in the RML template file?
def create_pdf:
name = "My Name"
with open('/file.rml') as rml:
data = rml.read()
pdf = rml2pdf.parseString(data)
with open(f"/newpdf.pdf", 'wb') as output:
output.write(pdf.read())
return HttpResponse(status=200)
Here is the template file.rml:
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!DOCTYPE document SYSTEM "rml_1_0.dtd">
<document filename="file.rml">
.....
<story>
<para style="h1-center">[[name]]</para> <!-- Name value should appear here -->
</story>
</document>
So how do I get the name variable value in the template?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
