Skip to content

🔥A command line tool to generate PDF and text files from csv data and Freemarker templates.🔥

Notifications You must be signed in to change notification settings

redking00/csv2pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csv2pdf

Java CI with Maven

🔥A command line tool to generate PDF (using Flyingsaucer) or text files from csv data and Freemarker templates🔥

How it works?

+--------------+           +--------------+                                                    
|   CSV data   |           | FTL template |                                                   
+--------------+           +--------------+                                                   
        |                          |                                                          
        |                          |                                                           
        v                          v                                                           
+--------------+           +--------------+         +--------------+          +--------------+ 
|   CsvJDBC    |---------->|  Freemarker  |----/--->|    JSoup     |--------->| FlyingSaucer | 
+--------------+           +--------------+         +--------------+          +--------------+ 
                                   |                                                  |        
                                   /                                                  |
                                   |                                                  |        
                                   v                                                  v        
                           +--------------+                                   +--------------+ 
                           |   TXT file   |                                   |   PDF file   | 
                           +--------------+                                   +--------------+ 

Build:

  mvn clean package

Usage:

  java -jar csv2pdf.jar <options>

Options:

-csv_charset <arg>CSV file charset (optional, default 'UTF-8')
-csv_extension <arg>CSV file extesion (optional, default '')
-csv_file <arg>CSV input file (optional, use instead -csv_query)
-csv_folder <arg>CSV folder path (optional, default '.')
-csv_query <arg>CSV query command (optional, use instead -csv_file)
-csv_separator <arg>CSV separator character (optional, default ';')
-for_eachGenerate one file per data record (optional, see notes below)
-ftl_encoding <arg>FTL input file encoding (optional, default 'UTF-8')
-ftl_file <arg>FTL input file
-pdf <arg>PDF output file (optional, use instead -txt)
-dpi <arg>PDF output file dpi (optional, default 96)
-txt <arg>TXT output file (optional, use instead -pdf)
-txt_charset <arg>TXT output file charset (optional, default 'UTF-8')

NOTES:

  • csv2pdf 2.0.0 and above uses freemarker's square bracket tag syntax and square bracket interpolation syntax.
  • Iterate "rows" collection inside your template if you are not using the -for_each option
  • You can use a templated output file name if using the -for_each option
  • See the examples folder!

Example 1:

  java -jar csv2pdf.jar -csv_file data.csv -ftl_file template.ftl -pdf output.pdf

Example 2:

  java -jar csv2pdf.jar -csv_file data.csv -ftl_file template2.ftl -for_each -pdf 'output_${id}.pdf'

Any idea, suggestion or comment is always appreciated