How can I generate a horizontal pdf with thymeleaf and spring?

2

I have a system that has personas registered, and I have generated a report of all of them with different datos but the pdf is downloaded vertically, so the campos as many are not displayed correctly, How can I generate the horizontal pdf?

 public static ByteArrayInputStream allPersonsReport(List<Person> persons) {

    Document document = new Document(PageSize.LEGAL.rotate());
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    try {
        ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
        templateResolver.setSuffix(".html");
        templateResolver.setTemplateMode("HTML");

        TemplateEngine templateEngine = new TemplateEngine();
        templateEngine.setTemplateResolver(templateResolver);

        Context context = setContextAllPerson(persons);

        String html = templateEngine.process("templates/report_all_persons", context);

        PdfWriter writer = PdfWriter.getInstance(document, out);
        document.open();
        InputStream is = new ByteArrayInputStream(html.getBytes());
        XMLWorkerHelper.getInstance().parseXHtml(writer, document, is);
        document.close();
        out.close();
    } catch (DocumentException ex) {
        Logger.getLogger(GeneratePdfReport.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return new ByteArrayInputStream(out.toByteArray());
    }
    
asked by Jeypi 10.08.2018 в 15:40
source

0 answers