From Construct to code
Your designs, made by the thousand
Every invoice, certificate or report you design in Construct is a template file (.slx). The
PDFStreamline library loads the same file in an app or on a server, fills it with data and makes the
documents — offline, exactly as they look in Construct.
Three steps
- Export the design. In Construct, File › Export for developers… saves the
.slxwith its sample data (invoice.data.json), or the design as code. - Load it in your language. Add the library to the project (Java, C#, Python or JavaScript) and load the file with the template API.
- Fill it from data and render. Bind your data — an object, a map, rows from a database — and render the PDF.
The code
import com.pdfstreamline.service.template.Templates;
// invoice.slx from Construct (File › Export for developers…)
Templates.loadXml("invoice.slx")
.bindModel(order) // your data: {{customer.name}}, the rows of lines…
.build()
.renderPdfToFile("invoice.pdf");The fields you placed in Construct ({{customer.name}}) read your data's properties; a table
set to Repeat for each row gets one row per item. The sample data file shows the shape the
design expects.
It works both ways
Templates move between Construct and code: XML written by code opens in Construct with File › Open, and a design edited in Construct loads in code unchanged. Designers keep designing; developers keep shipping.