A Node.js application that converts TypeScript React (TSX) files to PDF documents. This tool is particularly useful for generating PDF reports, documents, or visualizations from React components.
- Upload TSX files and convert them to PDF
- Supports React components with TypeScript
- Includes Tailwind CSS for styling
- Handles page breaks and formatting
- Server-side rendering of React components
- PDF generation with proper margins and formatting
- Node.js (v14 or higher)
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd TSX2PDF- Install dependencies:
npm install- Build the project:
npm run build- Start the server:
npm start-
The server will run on
http://localhost:3000 -
Upload a TSX file through the web interface or send a POST request to
/api/exportwith a file upload
Converts a TSX file to PDF.
Request:
- Method: POST
- Content-Type: multipart/form-data
- Body: file (TSX file)
Response:
- Content-Type: application/pdf
- Body: Generated PDF file
npm run dev- Start development server with hot reloadnpm run build- Build the TypeScript filesnpm start- Start the production server
.
├── dist/ # Compiled JavaScript files
├── public/ # Static files and frontend
├── uploads/ # Temporary file storage
├── server.ts # Main server file
├── package.json # Project dependencies
└── tsconfig.json # TypeScript configuration
- Express.js - Web server framework
- React - UI library
- Puppeteer - PDF generation
- Babel - TypeScript/React transpilation
- Multer - File upload handling
- Tailwind CSS - Styling
MIT
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request