completed first version of table based content

This commit is contained in:
jomu
2016-05-19 23:12:52 +00:00
parent 87838d3c0d
commit 36de01c8db
2 changed files with 55 additions and 30 deletions

View File

@ -60,22 +60,25 @@ public class PDFDocumentTest {
doc.addContent(informationContent);
TableContent informationContent2 = new TableContent (doc, doc.getStandardFont(), 400, 500);
TableContent informationContent2 = new TableContent (doc, doc.getStandardFont(), 400, 580);
List<String> headers = new ArrayList<>();
headers.add("Kunden-Nr");
headers.add("${customer.customerNumber}");
headers.add("${customerNumber}");
List<Integer> colSize = new ArrayList<>();
colSize.add (100);
colSize.add (100);
informationContent2.setHeader(headers, colSize);
informationContent2.addLine ("Rechnungs-Nr.:", "${invoiceNumber}");
informationContent2.addLine ("Ausgabe: ", "Dezember");
informationContent2.addLine ("Rechnungsdatum:", "${invoiceDate?date}");
doc.addContent(informationContent2);
jsonString = gson.toJson(doc);
System.out.println(jsonString);
File file = new File("c:/temp/test.ftlh");
FileUtils.writeStringToFile(file, jsonString, "UTF-8");
// create pdf
Configuration cfg = new Configuration(Configuration.VERSION_2_3_24);
cfg.setDirectoryForTemplateLoading(new File("c:/temp"));
@ -86,6 +89,8 @@ public class PDFDocumentTest {
Template template = cfg.getTemplate("test.ftlh");
PDFTemplate pdfDoc = new PDFTemplate(template);
pdfDoc.addToDatamodel("invoiceDate", new Date());
pdfDoc.addToDatamodel("customerNumber", "8755");
pdfDoc.addToDatamodel("invoiceNumber", "1234567");
pdfDoc.create("c:/temp/test.pdf");
}