JSPM

@funbrew/pdf

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 152
    • Score
      100M100P100Q91125F
    • License MIT

    FUNBREW PDF API client for Node.js

    Package Exports

    • @funbrew/pdf
    • @funbrew/pdf/src/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@funbrew/pdf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    @funbrew/pdf

    Official Node.js client library for the FUNBREW PDF API. Includes TypeScript type definitions.

    日本語ドキュメント

    Installation

    npm install @funbrew/pdf

    Quick Start

    const { FunbrewPdf } = require('@funbrew/pdf');
    
    const pdf = new FunbrewPdf('sk-your-api-key');
    
    // HTML to PDF
    const result = await pdf.fromHtml('<h1>Hello World</h1>');
    console.log(result.data.download_url);
    
    // URL to PDF
    const result = await pdf.fromUrl('https://example.com');
    
    // Template to PDF
    const result = await pdf.fromTemplate('invoice', {
      company_name: 'Acme Inc.',
      amount: '1,000',
    });

    Features

    // Generate PDF and send via email
    const result = await pdf.fromHtmlWithEmail(
      '<h1>Invoice</h1>',
      'customer@example.com',
      'Your invoice is ready',
    );
    
    // Test mode (no count, TEST watermark)
    const result = await pdf.test('<h1>Test</h1>');
    
    // File operations
    const info = await pdf.info('uuid.pdf');
    const buffer = await pdf.download('uuid.pdf');
    require('fs').writeFileSync('output.pdf', buffer);
    await pdf.delete('uuid.pdf');
    
    // Batch generate
    const batch = await pdf.batch([
      { type: 'html', html: '<h1>Doc 1</h1>' },
      { type: 'html', html: '<h1>Doc 2</h1>' },
    ]);
    
    // Merge PDFs
    const merged = await pdf.merge(['file1.pdf', 'file2.pdf']);
    
    // Usage stats
    const usage = await pdf.usage();

    Options

    const result = await pdf.fromHtml('<h1>Hello</h1>', {
      options: { 'page-size': 'A3', engine: 'quality' },
      expiration_hours: 168,
      max_downloads: 5,
      password: 'secret',
      watermark: 'CONFIDENTIAL',
    });

    TypeScript

    Full type definitions are included. No need for @types packages.

    import { FunbrewPdf, PdfResult } from '@funbrew/pdf';
    
    const pdf = new FunbrewPdf('sk-your-api-key');
    const result: PdfResult = await pdf.fromHtml('<h1>Hello</h1>');

    Error Handling

    const { FunbrewPdf, FunbrewError } = require('@funbrew/pdf');
    
    try {
      const result = await pdf.fromHtml('<h1>Hello</h1>');
    } catch (e) {
      if (e instanceof FunbrewError) {
        console.error(e.message);     // Error message
        console.error(e.statusCode);  // HTTP status code
      }
    }

    License

    MIT