CSV2PDF is a desktop application built with Java Swing that allows users to convert CSV (Comma-Separated Values) files into formatted PDF documents. It provides a graphical user interface to load CSV files, preview their content, and customize the layout of the output PDF.
- CSV Import: Load CSV files using a file chooser or by dragging and dropping them onto the application window.
- Data Preview: View the contents of the loaded CSV file in a table, with the ability to select or deselect specific rows for conversion.
- Customizable Delimiter: Supports common delimiters (comma, semicolon, tab, space) and allows for custom user-defined delimiters.
- Flexible PDF Layouts:
- Tabs: A simple text layout where columns are separated by space, resembling tabs.
- Tabular: A grid-based layout with visible cell borders for a classic table look.
- Page & Font Customization:
- Choose between Vertical (Portrait) and Horizontal (Landscape) page orientations.
- Select from various fonts (Helvetica, Times Roman, Courier) and font styles (Bold).
- Adjust the font size to fit your needs.
- Layout Adjustments:
- Center the table on the PDF page.
- Repeat table headers on each new page for better readability in multi-page documents.
- Direct PDF Generation and Printing:
- Convert and save the customized table as a PDF file.
- Print the generated PDF directly from the application.
Preview:
This project was built as a personal learning exercise to get hands-on experience with Java Swing and GUI development in Java. It is now open-sourced in the hope that others might find it useful or learn from it as well.
- Java Development Kit (JDK 17 or later)
- Apache Maven
-
Clone the repository:
git clone https://github.com/cemtbi/csv2pdf.git
-
Navigate to the project directory:
cd csv2pdf -
Compile and run the application using Maven:
mvn compile exec:java -Dexec.mainClass="com.ct.csv2pdf.GUI"
- Launch the application using the instructions above.
- Import a CSV file by clicking the
...button next to the filename field or by dragging and dropping a.csvfile onto the application window. - Preview Data: Once a file is loaded, a preview will appear in the "CSV Preview" section.
- Set the Delimiter: Choose the correct delimiter for your file from the "Delimeter" dropdown. If your delimiter is not listed, select "Other" and enter it in the text field. The preview table will update accordingly.
- Select Rows: By default, all data rows are selected for conversion. Uncheck the boxes in the first column of the preview table to exclude specific rows from the PDF. Use the
Select allbutton to toggle the selection for all rows. - Configure Layout Options:
- PDF Layout: Choose between
Tabs(no borders) andTabular(with borders). - Page orientation: Select
VerticalorHorizontal. - Font: Set the desired font name and size.
- Checkboxes: Enable
Centeredto center the content horizontally orTable header repeatingto repeat headers on every new page.
- PDF Layout: Choose between
- Generate PDF:
- Click
Convertto open a file dialog and save the output as a PDF. - Click
Printto open the system's print dialog and print the generated PDF directly.
- Click
This project relies on the following external libraries:
- Apache PDFBox: For creating and manipulating PDF documents.
- OpenCSV: For parsing and reading CSV files.
This project is licensed under the MIT License. See the LICENSE.md file for details.

