Convert PDF to ZPL
This API is used to convert PDF documents directly to ZPL code compatible with Zebra printers.
To use this feature provide a base64 encoded PDF to the pdfBase64
parameter.
The API also support rotating and scaling the PDF document.
API Usage
The API endpoint is: https://html-to-zpl.p.rapidapi.com/pdf2zpl
The API key provided by Rapid API must be set in the HTTP header X-RapidAPI-Key
.
The following parameters are supported by the PDF to ZPL conversion API:
Parameter Name | Required | Description | Example |
---|---|---|---|
height | yes | The height of the label in inches. | 6 |
width | yes | The width of the label, units are inches. | 4 |
pdfBase64 | yes | a base64 encoded PDF file. | Sample Download |
rotate | no | The number of degrees to rotate. Must be one of:
| 90 |
scale | no | Scaling/zooming options:
| contain |
dpi | no | The Zebra printer resolution in dpi (dots per inch):
| 203 |
pages | no | This parameter allows you to selectively convert pages from a multi-page PDF document into ZPL format. Acceptable values include:
1 (only the first page is converted). | all 1,3,5 |
The parameters can be sent via the body of POST
request
either as JSON (using the content-type application/json
)
or form-encoded (using the content-type: application/x-www-form-urlencoded
header).
Make sure that the size of the PDF document matches the label size given in the width
and height
parameters exactly,
otherwise some content might be cropped off.
Command Line Example (using curl)
First, let's download a sample 4x6" shipping label PDF:
wget https://www.htmltozpl.com/img/sample-label.pdf
The PDF file can be converted to base64 using the base64
tool on Linux and Mac OS X. Note that the -w0
parameter is required to omit any line breaks in the encoding process.
base64 -w0 sample-label.pdf > sample-label.base64
You should now have a file sample-label.base64
in your current directory. If you open that file in a text editor, you should see a single long ASCII string.
If you want to compare this file, you can download our reference.
We can now send the base64 encoded file to the PDF to ZPL conversion API with the following curl
command.
The parameter --data-urlencode [email protected]
tells curl to use the content of the sample-label.base64
file in the pdfBase64
API parameter.
Please replace the API_KEY
in the example with your key from Rapid API.
curl --request POST \
--url https://html-to-zpl.p.rapidapi.com/pdf2zpl \
--header 'content-type: application/x-www-form-urlencoded' \
--header 'x-rapidapi-host: html-to-zpl.p.rapidapi.com' \
--header 'x-rapidapi-key: API_KEY' \
--data width=4 \
--data height=6 \
--data-urlencode [email protected] \
> sample-label.zpl
If everything went well, you will have a sample-label.zpl
in your current directory.
This file contains the rendering of the PDF in ZPL and can be sent directly to a network attached printer using
the tool netcat:
nc -N 192.168.1.234 9100 < sample-label.zpl
This is the resulting label printed on a Zebra GK420t:

Postman Configuration
Refer to the following screenshots for Postman configuration details: