# PDF Generation Service
This service provides an API for generating PDF documents from HTML content using Puppeteer.
## Prerequisites
Ensure you have Node.js installed on your system. You can download it from [nodejs.org](https://nodejs.org/).
## Installation
First, clone the repository and install the necessary dependencies:
```bash
npm installTo start the server on port 8080, run:
node server.jsThis will launch the server and it will listen on http://localhost:8080. The primary endpoint for generating PDFs is:
POST /services/pdf-engine/print
You can test the PDF generation service using the provided script. Ensure you have curl installed on your system to use the script. Run:
./test.shThis script will make a POST request to the local server with a sample URL to generate a PDF.
To build the Docker image and push it to your registry, run:
./update_image.shEnsure that you have Docker installed and configured correctly, and that you are logged into your Docker registry.
- Update
./test.shand./update_image.shwith the correct commands according to your server configuration and registry details. - Adjust the environment variables and paths as necessary to fit your deployment environment.
### Creating Script Files
You need to create the `test.sh` and `update_image.sh` script files as mentioned in the README:
#### test.sh
```bash
#!/bin/bash
# Simple script to test the PDF generation service
curl -X POST http://localhost:8080/services/pdf-engine/print \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'
Make sure to give executable permissions:
chmod +x test.sh#!/bin/bash
# Script to build and push Docker image
docker build -t your-registry/your-image-name:tag .
docker push your-registry/your-image-name:tagAgain, set the executable permissions:
chmod +x update_image.shThese scripts provide basic automation for testing and deploying your service. Adjust the content of the scripts based on your specific registry, tagging strategy, and payload requirements.