This project is a TypeScript-based WebSocket server that uses Puppeteer to generate PDFs from HTML content. Clients can connect to this WebSocket server, send HTML as a message, and receive a PDF in response.
- WebSocket server built with TypeScript.
- PDF generation from HTML using Puppeteer.
- Efficient handling of PDF generation and data transmission.
Before you begin, ensure you have met the following requirements:
- Node.js installed (version 12 or higher).
- TypeScript installed globally (
npm install -g typescript
). - Puppeteer dependencies installed on your system.
Clone the repository and install dependencies:
git clone https://github.com/your-username/websocket-puppeteer-pdf.git
cd websocket-puppeteer-pdf
npm install
To run the server, use the following command:
npm start
The server will start on localhost
with the default port 3000
. Clients can connect to the WebSocket server at ws://localhost:3000
.
Clients should send HTML content as a string message to the WebSocket server. The server will process the HTML, generate a PDF, and send the PDF file back as a buffer.
To make changes to the project, edit the TypeScript files in the source directory. After making changes, compile the TypeScript code using:
npm run build
This command compiles the TypeScript files into JavaScript in the dist
folder.
Contributions to the WebSocket Puppeteer PDF Generator are welcome. To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Make your changes.
- Commit your changes (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Create a new Pull Request.
This project is licensed under the MIT License.
If you have any questions or feedback, please contact me at [email protected]
.