Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/iamtheritikraj/pdfgeneratorservice


https://github.com/iamtheritikraj/pdfgeneratorservice

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

PDF Generator Service


PDFGeneratorService is a Spring Boot application designed to generate PDF invoices that can be used via POSTMAN or Swagger UI.
It allows you to submit invoice data via a REST API and generate a downloadable PDF invoice.
The generated PDFs are stored locally, and if the same data is provided again, the system retrieves the existing PDF instead of regenerating it.

How to Use

1. Download PDF



GET: api/pdf/download?fileName="example.pdf"

Use this endpoint to download an already generated PDF by providing the fileName parameter in the query string.

2. Generate PDF



POST: api/pdf/generate

Use this endpoint to generate a new PDF by providing the invoice data in the request body.

Sample Request Body



{
"seller": "XYZ Pvt. Ltd.",
"sellerGstin": "29AABBCCDD121ZD",
"sellerAddress": "New Delhi, India",
"buyer": "Vedant Computers",
"buyerGstin": "29AABBCCDD131ZD",
"buyerAddress": "New Delhi, India",
"items": [
{
"name": "Product 1",
"quantity": "12 Nos",
"rate": 123.00,
"amount": 1476.00
}
]
}

Required Header


Content-Type: application/json

Features



  • REST API to accept invoice data and generate a PDF based on the received information.

  • Ability to download the generated PDF by providing the file name.

  • Stores the generated PDF in local storage and retrieves it when the same data is provided again to avoid regeneration.

Technology Stack




  • Java: Programming language used to build the application.


  • Spring Boot: Framework used to create the REST API service.


  • Thymeleaf: Template engine used to generate HTML content for the PDF.


  • iText: Library used to convert HTML content to a PDF document.

Endpoints



Method
URL
Description




GET
/api/pdf/download?fileName="example.pdf"
Download the PDF by file name.


POST
/api/pdf/generate
Generate a new PDF invoice by submitting invoice data.

Installation and Setup



  1. Clone the repository to your local machine.

  2. Open the project in your preferred IDE.

  3. Ensure you have Java 8+ and Maven installed.

  4. Run mvn clean install to build the project.

  5. Run the application using mvn spring-boot:run.

License


This project is licensed under the MIT License.