How to Convert PDF Colors with cURL

Learn how to use cURL to change PDF color profiles with pdfRest Convert PDF Colors API tool
Share this page

Why Convert PDF Colors with cURL?

The pdfRest Convert PDF Colors API Tool allows users to change the color profile of a PDF document. This tutorial will show you how to send an API call to Convert PDF Colors using cURL, a command-line tool for transferring data with URLs.

In a real-world scenario, you might need to convert the color profile of a PDF for printing purposes. For instance, converting a PDF from RGB to CMYK ensures that the colors will print correctly on a commercial printer. Similarly, converting to sRGB can make sure the colors are consistent across different screens and devices.

Convert PDF Colors with cURL Code Example

curl -X POST "" \
  -H "Accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  -F "file=@/path/to/file" \
  -F "output=example_out" \
  -F "color_profile=srgb"

Source: GitHub

Breaking Down the Code

Let's break down the code to understand each part:

curl -X POST ""

This line initiates a POST request to the endpoint, which is the API endpoint for converting PDF colors.

-H "Accept: application/json"

This header specifies that the client expects the server to return data in JSON format.

-H "Content-Type: multipart/form-data"

This header indicates that the request body will be sent as a multipart/form-data, which is necessary when uploading files.

-H "Api-Key: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

This header includes your API key, which authenticates your request. Replace xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx with your actual API key.

-F "file=@/path/to/file"

This form field specifies the file to be uploaded. Replace /path/to/file with the actual path to your PDF file.

-F "output=example_out"

This form field specifies the name of the output file. In this case, the output file will be named example_out.

-F "color_profile=srgb"

This form field specifies the color profile to which the PDF will be converted. Here, srgb is used, but other color profiles like CMYK can also be specified.

Beyond the Tutorial

In this tutorial, you learned how to use cURL to send an API request to convert the color profile of a PDF using the pdfRest Convert PDF Colors API Tool. This can be particularly useful for ensuring color consistency across different devices and printing processes.

To explore more functionalities, you can demo all of the pdfRest API Tools in the API Lab. For detailed information on all available API endpoints and parameters, refer to the API Reference Guide.

Note: This is an example of a multipart API call. Code samples using JSON payloads can be found at GitHub.

Generate a self-service API Key now!

Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.

Compare Plans
Contact Us