Generate a Barcode Using PDF.co’s Web API

4 Minutes Read

Create a barcode image from a text value using PDF.co. This example generates a Code128 barcode containing an invoice number.

Step 1: Open the API Tester

Sign in to your PDF.co account, then open the Barcode Generator API Tester.

Select Try it and provide your PDF.co API key in the x-api-key authorization field when prompted.

The endpoint is:

POST https://api.pdf.co/v1/barcode/generate

Step 2: Configure the Request

Use these request parameters:

{
  "type": "Code128",
  "value": "INV-123456",
  "name": "barcode.png",
  "inline": false,
  "async": false
}
  • type: The barcode format. This example uses Code128.
  • value: The text to encode. Replace it with your invoice number or other value.
  • name: The generated image’s filename.
  • inline: Set to false to receive a downloadable image URL.
  • async: Set to false for this synchronous example.

PDF.co also supports QRCode, DataMatrix, Code39, and other formats. Check the Barcode Generator documentation for supported types and additional options.

Step 3: Generate and Download the Barcode

Submit the request and review the response.

On success, open the returned url to view the barcode image. Download it before the temporary link expires, then scan it with a compatible barcode reader to confirm that it contains your expected value.

To integrate the request into your application, use the API Tester’s language selector to view a code example in your preferred language.

Related Tutorials

See Related Tutorials