Why it happens, and why raising the limit is not enough
Phone photos are often 3 to 8 MB, scanned PDFs easily 10 MB or more, and iPhones save photos as HEIC, which many forms refuse. Your limit protects your server and your mailbox, so raising it only moves the problem.
Asking visitors to “compress the file and try again” loses many of them. The fix is to do it for them, at the moment they pick the file.
How the upload helper works
- 1
The visitor picks a file
Exactly as today, by clicking or by dropping it on your form.
- 2
If it is over your limit, a small window reduces it
PDFs (including scans), JPG, PNG and WebP are reduced in the visitor’s browser. iPhone HEIC photos become JPG.
- 3
Your form receives the smaller file
It replaces the original in the file field, so your form and your server code do not change.
Files under the limit, and other types (Word, ZIP…), go through untouched with no window. If a file cannot be reduced enough, the window says so and the original goes through, so your form shows its usual error.
Nothing is uploaded to PDFkind: the file is processed on the visitor’s device and your server receives only the final file, through your form.
Add it to your form
Add `data-pdfkind-max` with your limit to the file field, and the PDFkind script once on the page:
<input type="file" name="document" data-pdfkind-max="5MB">
<script src="https://pdfkind.com/embed.js" defer></script>Using a drag-and-drop area? Put the attribute on the area instead: it covers both dropping and its “browse” button.
<div class="dropzone" data-pdfkind-max="5MB">…</div>WordPress and form builders
With Contact Form 7, WPForms, Gravity Forms and other builders, you often cannot add attributes to the file field. Put the limit on the script instead, and it applies to every file field on the page:
<script src="https://pdfkind.com/embed.js" data-max="5MB" defer></script>Add that line to the page with a Custom HTML block, or to your site’s footer to cover every form. The WordPress and form builders page has the details for each builder.
React, Vue, Angular or your own code
The attribute works on file inputs rendered by any framework, including react-dropzone. See React, Vue and Angular.
To reduce a file from your own code, call `PDFkind.fit()`; the JavaScript API page lists every outcome.
const smaller = await PDFkind.fit(file, { max: '5MB' });For files that arrive another way
If visitors send you files by email, you can also embed the full compressor on your help page, so they can shrink a PDF themselves:
Frequently asked questions
Do I have to change my server code?+
No. Your form receives a normal file in the same field. Only its size changes.
Are the files uploaded to PDFkind?+
No. They are reduced in the visitor’s browser. PDFkind never sees them.
What happens if the window cannot open?+
With a strict Content Security Policy, a blocked network or an old browser, the original file goes through within a few seconds and your form behaves as before. See security for the CSP settings.
Which file types are reduced?+
PDF, JPG, PNG and WebP. HEIC photos are converted to JPG. Other types go through untouched.
Is it free?+
Yes, with no limit on visitors and no ads in the window.
Add Compress PDF to your website
Free, no ads, no sign-up. Paste one line of code and your visitors use it right on your pages.
- Files never leave your device
- Free, no signup, no watermark
- Works on any browser