Developer docs: How it works
Upload helper
Upload helper
Stop “file too big” errors: PDFs, photos and iPhone HEIC images are reduced in the visitor’s browser and handed to your form, which receives a file that fits.
Where to put the limit
Add data-pdfkind-max where files come in. The closest element with the attribute wins, so one field can have its own limit inside a form that has another.
| Your upload | Put data-pdfkind-max on | Example |
|---|---|---|
| A file field | the input | <input type="file" data-pdfkind-max="5MB"> |
| A drag-and-drop area | the area (covers dropping and its “browse” button) | <div class="dropzone" data-pdfkind-max="5MB"> |
| A whole form | the form | <form data-pdfkind-max="5MB"> |
| Every field on the page | the script tag, as data-max | <script src="…/embed.js" data-max="5MB" defer> |
Writing the limit
Write it like 5MB, 500KB, 2.5 MB or 800ko, or as a number of bytes such as 5000000. 1 MB is 1,000,000 bytes.
5MB: it’s slightly lower, so reduced files always pass your check.What happens to each file
| File | What the helper does |
|---|---|
| Under the limit | Nothing. It goes straight to your form, no window opens. |
| PDF over the limit | Reduced: fonts and duplicate data are slimmed first, then images are lightened only as much as needed. Text stays sharp and selectable. |
| JPG, PNG, WebP over the limit | Re-encoded and resized only as much as needed. A PNG without transparency that can’t fit becomes a JPG. |
| HEIC or HEIF (iPhone photos) | Always turned into JPG, even under the limit, since most forms don’t accept HEIC. |
| Any other file (Word, ZIP…) | Left untouched. |
| Several files at once | Each one is handled in turn; your field receives all of them. |
What the visitor sees
A small PDFkind window opens over your page with “Reducing your file…”, then shows the result (“Reduced from 8.2 MB to 3.9 MB”) and closes by itself. Most files take 1 to 5 seconds; a long scan on an older phone can take about 15.
| If | Then |
|---|---|
| the file can’t get under the limit | The window explains why, then the original file goes through so your form shows its usual error. |
| the visitor closes the window | The original file goes through. |
| the window can’t load within 8 seconds | The original file goes through at once (offline, or blocked by your security rules). |
| the script itself can’t load | Nothing changes on your page: your form works as before. |
Language of the window
The window follows your page’s <html lang>. Set data-lang="fr" on the field or the script to choose. See Languages.
Frameworks
Last updated November 3, 2026 · Questions: contact@pdfkind.com