Code Monkey home page Code Monkey logo

freemarker2pdf's Introduction

freemarker2pdf

Build Status

Java utilities for converting freemarker template to pdf file.

You can use this library to pass parameters to freemarker template and convert it to html or pdf. There is also helper method to insert image into an existing pdf file. The output pdf can be written to disk or as InputStream (for downloading). Please see javadoc for more details: https://rawgit.com/tonyvu2014/freemarker2pdf/master/src/main/java/com/tonyvu/freemarker2pdf/doc/index.html

There are 2 ways of converting: using iText library or flying saucer library. Generally, it is much better to use the flying saucer way since it supports broader css styles while iText support for css is limited.

Steps to create the jar:

  1. Go to your git repo, clone the project with git clone https://github.com/tonyvu2014/freemarker2pdf.git
  2. Run mvn clean package -Dmaven.test.skip=true

The jar file will be generated under target folder

To build and run the unit test:

  1. Go to the file /src/test/java/com/tonyvu/freemarker2pdf/FreeMarker2PdfTest.java and update the templatePath and pdfPath to reflect setup in your environment.
  2. Run mvn clean package. If the tests fail, errors will occur. (Or you can run mvn test)

You can copy the generated freemarker2pdf-<version>.jar to your project to use directly or you can install it to local repository. To install the jar your local repository, issue this command from the project root folder:

mvn install:install-file -Dfile=target/freemarker2pdf-<version>.jar -DpomFile=pom.xml

After that, to use the library in your project, just add the dependency to pom.xml like below:

<dependency>
   <groupId>com.tonyvu</groupId>
   <artifactid>freemarker2pdf</artifactId>
   <version>....</version>
</dependency>

The HtmlUtils class from the library provides static method to convert a freemarker template to html. The PdfUtils class provides various methods to convert html or freemarker template to pdf file.

Please see the javadoc to find out how to use the library: https://rawgit.com/tonyvu2014/freemarker2pdf/master/src/main/java/com/tonyvu/freemarker2pdf/doc/index.html

freemarker2pdf's People

Contributors

tonyvu2014 avatar

Watchers

James Cloos avatar tinker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.