PDF Compression & File Size
Reduce PDF file size for faster delivery, lower storage costs, and better email compatibility.
Overview
Smaller PDFs download faster, cost less to store, and fit within email attachment limits. This guide covers strategies to keep your generated PDFs lean.
Image Optimization
Images are the #1 contributor to PDF file size. Optimize them before using in templates:
- Compress images — Use tools like TinyPNG or Squoosh before uploading
- Right-size images — An image displayed at 200×100px doesn't need to be 2000×1000px
- Use JPEG for photos — Much smaller than PNG for photographic content
- Use SVG for logos/icons — Vector graphics scale without file size increase
- Avoid embedded screenshots — They're typically very large
File Size Targets
| Document Type | Target Size | Notes |
|---|---|---|
| Invoice (text only) | < 50 KB | Minimal images |
| Invoice (with logo) | < 150 KB | Optimized logo |
| Certificate | < 200 KB | Background image |
| Multi-page report | < 500 KB | Charts and tables |
| Email attachment limit | < 10 MB | Most email providers |
Template Design Tips
- Use CSS borders instead of image borders — much smaller
- Use background colors instead of full-page background images
- Minimize the number of custom fonts — each font adds to file size
- Use icon elements (vector) instead of icon images (raster)
- Avoid decorative images that don't add informational value
Document Stack automatically optimizes fonts by subsetting — only the characters used in the document are included in the PDF.
Font Impact on Size
| Scenario | Approx. Size Impact |
|---|---|
| System font (no embedding) | ~0 KB |
| 1 custom font, 1 weight | +20–40 KB |
| 1 custom font, 4 weights | +60–120 KB |
| 3 custom fonts | +100–300 KB |
Monitoring File Sizes
- Check generated PDF size via the API response metadata
- Set up alerts if average file size exceeds your target
- Review templates periodically for optimization opportunities
Quick Win
The single most impactful optimization is usually replacing a large background image with a smaller, compressed version or a solid background color.Next Steps
- Image Optimization — Detailed image guide
- Performance — Generation speed optimization
- Email Attachments — Size limits for email