Skip to main content

Add Margin to PDF

EditAdd Margin to PDF

The Add Margin to PDF API adds custom margins to any side of the PDF. You send the PDF (docContent, docName) and optional marginLeft, marginRight, marginTop, marginBottom (in millimeters, 0–100). The page size is adjusted to accommodate the margins. The API returns the PDF with the new margins. Use the tester below to try it; more details are in the sections that follow.

Try the Add Margin to PDF API

Quick reference

Endpoint: POST /api/v2/AddMargin · Required: api-key, docContent, docName

Try it live

Use the form below to send your API key and PDF (Base64), and set left/right/top/bottom margins in mm. The response is the PDF with margins applied. No code required—fill the fields and click Send request.

Loading API Tester...

Overview, parameters, and use cases

What is Add Margin to PDF?

This endpoint adds custom margins to the left, right, top, and bottom of each page. Margins are in millimeters (0–100). The page size is changed to accommodate the margins, so content is not cropped—the effective printable area is reduced. Use it when you need consistent margins for binding, printing, or layout.

Key features

  • Per-side marginsmarginLeft, marginRight, marginTop, marginBottom in mm (0–100).
  • Page size adjustment – The API adjusts page size so margins are added; content stays intact.
  • Optional – Omit a margin to leave that side unchanged (or use 0).
Best for

Use when preparing PDFs for print (binding margins) or when you need a consistent gutter. Combine with Add Page Number to PDF or Add HTML Header Footer to PDF after setting margins so headers/footers sit in the margin area.

Prerequisites

Before using this endpoint, make sure you have:

  • A valid PDF4me API key (Get your API Key)
  • A PDF document in Base64 format or a public URL to a PDF file

Response Format

The API returns a PDF document with the specified margins applied. The page size will be adjusted to accommodate the margins.

Get Help