Skip to main content

Add Barcode to PDF

BarcodeAdd Barcode to PDF

The Add Barcode to PDF API embeds barcodes or QR codes into your PDFs. You send the PDF as Base64 (docContent), docName, the text to encode, barcodeType (e.g. qrCode, code128, dataMatrix), pages (e.g. 1-3 or all), alignment (alignX, alignY), and optional size and margin settings. The API returns the PDF with the barcode placed on the chosen pages. Use the tester below to try it; more details are in the sections that follow.

Try the Add Barcode to PDF API

:::note Quick reference Endpoint: POST /api/v2/addbarcode · Required: api-key, docContent, docName, text, barcodeType, pages, alignX, alignY, hideText :::

:::info Try it live Use the form below to send your API key, PDF (Base64), barcode content, type, target pages, and alignment. The response is the modified PDF with the barcode embedded. No code required—fill the fields and click Send request. :::

Loading API Tester...

Overview, parameters, and use cases

What is Add Barcode to PDF?

This endpoint places one or more barcodes or QR codes onto specified pages of a PDF. You choose the encoded text, barcode type (e.g. QR Code, Code128, DataMatrix), target pages, and position via horizontal and vertical alignment. Optional settings control size (mm or points), margins, opacity, and whether the human-readable text appears above or below the barcode.

Key features

  • 150+ barcode types – Including QR Code, Code128, DataMatrix, PDF417, Aztec, HanXin, Code39, EAN13/EAN8, UPC-A/UPC-E and more.
  • Flexible placementalignX (Left, Center, Right) and alignY (Top, Middle, Bottom) with optional margins in mm or points.
  • Page targeting – Use pages (e.g. 1-3, all) to add the barcode only where needed.
  • Size and opacityheightInMM / widthInMM or heightInPt / widthInPt; opacity 0–100. Use 0 for auto size where supported.

:::tip Best for Use for invoices, tickets, labels, or any PDF that needs scannable codes. Combine with Read Barcode from PDF to verify, or Create Barcode if you only need a standalone barcode image. :::

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
  • The barcode type and text you want to encode

Response Format

The API returns a JSON response with:

  • File Content: Binary content of the processed PDF document with embedded barcodes (Base64 encoded)
  • File Name: Filename for the processed PDF document

Get Help