@pdfx-dev/cli
v0.0.1-alpha.1
Published
CLI for PDFX - dev server and PDF generation
Maintainers
Readme
@pdfx-dev/cli
CLI and server for PDFX - PDF generation from React components.
Alpha Release - The
servecommand works.devandaddcommands are coming soon.
Installation
npm install -D @pdfx-dev/cliCommands
pdfx serve
Start the PDF generation server.
npx pdfx serve
npx pdfx serve --port 3456
npx pdfx serve --max-concurrent 10
npx pdfx serve --timeout 60000Options:
| Option | Env Variable | Default | Description |
|--------|--------------|---------|-------------|
| --port | PDFX_PORT | 3456 | Server port |
| --max-concurrent | PDFX_MAX_CONCURRENT | 5 | Max concurrent PDF generations |
| --timeout | PDFX_TIMEOUT | 30000 | Request timeout in ms |
Server Endpoints
# Generate PDF from HTML
POST /generate
Content-Type: application/json
{ "html": "<html>...</html>" }
# Returns: application/pdf
# Health check
GET /health
# Returns: { "status": "ok", "browser": "connected", ... }Usage with @pdfx-dev/react
import { generate, Document, Page } from '@pdfx-dev/react';
process.env.PDFX_HOST = 'http://localhost:3456';
const pdf = await generate(
<Document>
<Page>
<h1>Hello World</h1>
</Page>
</Document>
);Embedding in Your Server
import { createServer } from '@pdfx-dev/cli/server';
const pdfServer = createServer({ port: 3456 });
await pdfServer.start();
// Or mount routes in Express
app.use('/pdf', pdfServer.routes);Docker (Coming Soon)
docker run -p 3456:3456 ghcr.io/pdfxjs/cli serveLicense
MIT
