An open API service indexing awesome lists of open source software.

https://github.com/redking00/csv2pdf

🔥A command line tool to generate PDF and text files from csv data and Freemarker templates.🔥
https://github.com/redking00/csv2pdf

cli command-line-tool csv easy-to-use flyingsaucer freemarker ftl java pdf pdf-generation templated-content text-generation

Last synced: 11 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# csv2pdf
![Java CI with Maven](https://github.com/redking00/csv2pdf/workflows/Java%20CI%20with%20Maven/badge.svg)




🔥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