Skip to content

EsteMac/TSX2PDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TSX to PDF Converter

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.

Features

  • 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

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn

Installation

  1. Clone the repository:
git clone <repository-url>
cd TSX2PDF
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Usage

  1. Start the server:
npm start
  1. The server will run on http://localhost:3000

  2. Upload a TSX file through the web interface or send a POST request to /api/export with a file upload

API Endpoints

POST /api/export

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

Development

  • npm run dev - Start development server with hot reload
  • npm run build - Build the TypeScript files
  • npm start - Start the production server

Project Structure

.
├── 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

Dependencies

  • Express.js - Web server framework
  • React - UI library
  • Puppeteer - PDF generation
  • Babel - TypeScript/React transpilation
  • Multer - File upload handling
  • Tailwind CSS - Styling

License

MIT

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

About

A Node.js application that converts TypeScript React (TSX) files to PDF documents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors