@pixldocs/canvas-renderer 0.3.27 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/index.cjs +1064 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +1064 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -89,6 +89,41 @@ function TemplatePreview({ templateId, formSchemaId, sectionState, themeId }) {
|
|
|
89
89
|
**Pros**: Lightweight DOM (just `<img>` tags), canvas is disposed after capture, fast for multi-page
|
|
90
90
|
**Cons**: Not interactive, requires re-render to update
|
|
91
91
|
|
|
92
|
+
### Approach C: Vector PDF Export
|
|
93
|
+
|
|
94
|
+
Renders all pages as SVGs and assembles them into a vector PDF using jsPDF + svg2pdf.js. Best for print-quality exports.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { PixldocsRenderer } from '@pixldocs/canvas-renderer';
|
|
98
|
+
|
|
99
|
+
const renderer = new PixldocsRenderer({
|
|
100
|
+
supabaseUrl: 'https://xxx.supabase.co',
|
|
101
|
+
supabaseAnonKey: 'eyJ...',
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// From form data (V2 sectionState)
|
|
105
|
+
const { blob, totalPages } = await renderer.renderPdfFromForm({
|
|
106
|
+
templateId: 'your-template-id',
|
|
107
|
+
formSchemaId: 'your-schema-id',
|
|
108
|
+
sectionState: { section_abc: { name: 'John' } },
|
|
109
|
+
title: 'My Document',
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Download the PDF
|
|
113
|
+
const url = URL.createObjectURL(blob);
|
|
114
|
+
const a = document.createElement('a');
|
|
115
|
+
a.href = url;
|
|
116
|
+
a.download = 'document.pdf';
|
|
117
|
+
a.click();
|
|
118
|
+
URL.revokeObjectURL(url);
|
|
119
|
+
|
|
120
|
+
// Or from a pre-resolved config
|
|
121
|
+
const result = await renderer.renderPdf(templateConfig, { title: 'My Doc' });
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Pros**: Vector output (infinite zoom), small file size, print-quality
|
|
125
|
+
**Cons**: No interactivity, requires jsPDF/svg2pdf.js (bundled as dependencies)
|
|
126
|
+
|
|
92
127
|
---
|
|
93
128
|
|
|
94
129
|
## API Reference
|