open-index/open-npm huggingface dataset:
npm package: @polotno/pdf-import
Description: Convert PDF files into Polotno JSON format
Author: Anton Lavrenov
Latest version: 0.0.6

# Polotno PDF Import

Convert PDF files into [Polotno](https://polotno.com/) JSON format.

For full documentation and demo, see [PDF Import Guide](https://polotno.com/docs/pdf-import).

## Installation

```bash
npm install @polotno/pdf-import
```

## Usage

### Node.js

```ts
import fs from 'fs';
import { pdfToJson } from '@polotno/pdf-import';

const pdfBuffer = fs.readFileSync('document.pdf');
const json = await pdfToJson({ pdf: pdfBuffer });
console.log(json);
// { width: 612, height: 792, pages: [{ id: '...', children: [] }] }
```

### Browser

```ts
import { pdfToJson } from '@polotno/pdf-import';

const input = document.querySelector('input[type="file"]');
input.addEventListener('change', async (e) => {
  const file = e.target.files[0];
  const pdfBuffer = await file.arrayBuffer();
  const json = await pdfToJson({ pdf: pdfBuffer });
  console.log(json);
});
```
npm package: @polotno/pptx-export
Description: Convert Polotno JSON into PPTX file
Author: Anton Lavrenov
Latest version: 0.0.1

# Polotno to PPTX

Convert Polotno JSON into PowerPoint PPTX files.

```bash
npm install @polotno/pptx-export
```

## Usage

```js
import { jsonToPPTX } from '@polotno/pptx-export';

const json = store.toJSON();
await jsonToPPTX({ json, output: 'design.pptx' });
```

## Development

```bash
npm run build  # Build the library
npm test       # Run tests
npm run dev    # Start demo app at http://localhost:5173
```
npm package: @polotno/svg-import
Description: Convert SVG files into Polotno JSON format
Author: Anton Lavrenov
Latest version: 0.0.15

# Polotno SVG Import

Convert SVG files into Polotno JSON format.

## Installation

```bash
npm install @polotno/svg-import
```

## Usage

```typescript
import { svgToJson } from '@polotno/svg-import';

const svg = `<svg viewBox="0 0 800 600">
  <text x="100" y="100" font-size="24">Hello World</text>
  <rect x="200" y="200" width="100" height="100" fill="blue"/>
</svg>`;

const json = await svgToJson({ svg });

// Load into Polotno store
store.loadJSON(json);
```
npm package: @polotno/video-export
Description: Convert Polotno store into video file
Author: Anton Lavrenov
Latest version: 0.0.11

# Polotno to Video

Convert Polotno store into video files using browser-based video encoding.

## Installation

```bash
npm install @polotno/video-export
```

## Features

- ✅ Browser-based video encoding (no server required)
- ✅ Support for animations and timeline
- ✅ Multiple pages with durations
- ✅ **Audio support** with multiple tracks, delays, and volume control
- ✅ Customizable FPS and pixel ratio
- ✅ Progress tracking
- ✅ MP4 output format

## Usage

```typescript
import { storeToVideo } from '@polotno/video-export';
import { createStore } from 'polotno/model/store';

const store = createStore({ key: 'YOUR_KEY' });

// Export video
const videoBlob = await storeToVideo({
  store,
  fps: 30, // Frames per second (default: 30)
  pixelRatio: 2, // Pixel ratio for quality (default: 1)
  onProgress: (progress, frameTime) => {
    console.log(`Progress: ${Math.round(progress * 100)}%`);
    console.log(`Frame render time: ${frameTime}ms`);
  },
  // Optional: cancel the export
  // signal: new AbortController().signal,
});

// Download the video
const url = URL.createObjectURL(videoBlob);
const link = document.createElement('a');
link.href = url;
link.download = 'video.mp4';
link.click();
```

## Cancel / Abort

You can cancel an in-progress export with an `AbortController`:

```typescript
const controller = new AbortController();

const promise = storeToVideo({
  store,
  signal: controller.signal,
});

// Later...
controller.abort();

// `storeToVideo` will reject with an AbortError
await promise;
```

## How it works

1. **Timeline Calculation**: The function calculates the total duration from all pages and their durations
2. **Frame Rendering**: For each frame at the specified FPS:
   - Updates the store's current time
   - Selects the appropriate page
   - Renders the page to a data URL using `store.toDataURL()`
   - Draws the image to a canvas
3. **Video Encoding**: Uses Media Bunny to encode frames into MP4
4. **Output**: Returns a Blob that can be downloaded or displayed

## Audio Support

The library supports adding audio tracks to your videos. Audio tracks are automatically mixed with proper delays and volumes:

```typescript
// Add audio to your store
store.addAudio({
  src: 'https://example.com/audio.mp3',
  delay: 0, // Delay in ms before audio starts
  startTime: 0, // Relative start point in the audio (0-1)
  endTime: 1, // Relative end point in the audio (0-1)
  volume: 1, // Volume level (0-1)
});

// Export with audio (enabled by default)
const videoBlob = await storeToVideo({
  store,
  includeAudio: true, // default: true
});

// Or disable audio
const videoBlob = await storeToVideo({
  store,
  includeAudio: false,
});
```