Exemple #1
0
 private void loadHeaderAndFooter(PDFDocument doc, Map<String, Object> args)
     throws TemplateNotFoundException {
   Options options = doc.options;
   if (options == null) return;
   if (!StringUtils.isEmpty(options.HEADER_TEMPLATE)) {
     Template template = TemplateLoader.load(options.HEADER_TEMPLATE);
     options.HEADER = template.render(new HashMap<String, Object>(args));
   }
   if (!StringUtils.isEmpty(options.FOOTER_TEMPLATE)) {
     Template template = TemplateLoader.load(options.FOOTER_TEMPLATE);
     options.FOOTER = template.render(new HashMap<String, Object>(args));
   }
   if (!StringUtils.isEmpty(options.HEADER))
     doc.headerFooterList.add(
         new IHtmlToPdfTransformer.CHeaderFooter(
             options.HEADER, IHtmlToPdfTransformer.CHeaderFooter.HEADER));
   if (!StringUtils.isEmpty(options.ALL_PAGES))
     doc.headerFooterList.add(
         new IHtmlToPdfTransformer.CHeaderFooter(
             options.ALL_PAGES, IHtmlToPdfTransformer.CHeaderFooter.ALL_PAGES));
   if (!StringUtils.isEmpty(options.EVEN_PAGES))
     doc.headerFooterList.add(
         new IHtmlToPdfTransformer.CHeaderFooter(
             options.EVEN_PAGES, IHtmlToPdfTransformer.CHeaderFooter.EVEN_PAGES));
   if (!StringUtils.isEmpty(options.FOOTER))
     doc.headerFooterList.add(
         new IHtmlToPdfTransformer.CHeaderFooter(
             options.FOOTER, IHtmlToPdfTransformer.CHeaderFooter.FOOTER));
   if (!StringUtils.isEmpty(options.ODD_PAGES))
     doc.headerFooterList.add(
         new IHtmlToPdfTransformer.CHeaderFooter(
             options.ODD_PAGES, IHtmlToPdfTransformer.CHeaderFooter.ODD_PAGES));
 }
Exemple #2
0
 private void renderDocuments(Map<String, Object> args) {
   for (PDFDocument doc : docs.documents) {
     Request request = Http.Request.current();
     String templateName = PDF.resolveTemplateName(doc.template, request, request.format);
     Template template = TemplateLoader.load(templateName);
     doc.content = template.render(new HashMap<String, Object>(args));
     loadHeaderAndFooter(doc, args);
   }
 }