설명 없음

dengjia bcd5e475f7 update readme 2 달 전
core 74d08d0f1b mock data for cso report: section 2: incompleted 4 달 전
example-app d4a6bf9e72 Initial commit 7 년 전
.gitignore 395389ba25 mock data for cso report: section 1 4 달 전
README.md bcd5e475f7 update readme 2 달 전
mvnw d4a6bf9e72 Initial commit 7 년 전
mvnw.cmd d4a6bf9e72 Initial commit 7 년 전
pom.xml 2d72f8e527 copy & test alice.xhtml from flyingsauce example in UnitTest 6 달 전

README.md

使用说明

网上找到的一个小Project用来尝试flyingsaucer,可以省了一些脚手架的工作。https://github.com/cgenin/springboot.pdfgenerator

mvn test

然后检查 ls core/target/tmp-test/

alice.pdf是我从 https://github.com/flyingsaucerproject/flyingsaucer/tree/main/flying-saucer-examples/src/main/resources/demos/alice 拷贝来生成的。

见core/src/test/java/net/christophe/genin/spring/boot/pdfgenerator/core/PdfBuilderTest.java:test_alice

同理可以尝试其他的flyingsaucer的例子和特性,按列渲染Table可以使用Mustache的section能力, 在PdfBuilderTest里可以为Table提前准备好数据

pdfGenerator

An spring boot library for generating PDF files from an Xhtml file. This library also provide an mustache's template motor to dynamically generate pdf. This library use flying saucer for the pdf generation and the .

USAGE

Pdf Generator Builder

pdfgenerator is automatically added to spring configuration. The main class is an Builder to specifying template parameters. Inject directly this instance like this :

    @Autowired
    private PdfGeneratorBuilder pdfGeneratorBuilder;

Simple example - Generation from String template

this is an simple example of generation :

     Generator generator = pdfGeneratorBuilder
                    .create()
                    .withXhtml("<html><body>the universal response is {{response}}.</body></html>")
                    .build();
     Map<String, Object> data = new HashMap<>();
     data.put("response", "42");
     byte[] pdfBuffer =  generator.toBytes(data);