How to Convert PDF Files from RGB to CMYK with cURL

Learn how to use pdfRest API Toolkit to convert PDF colors from RGB to CMYK with cURL
Share this page

Why Convert PDF from RGB to CMYK with cURL?

The pdfRest Convert PDF Colors API Tool is a valuable resource for developers working with PDF documents that require precise color control, especially when converting from RGB to CMYK. This tutorial will guide you through the process of using cURL, a command-line tool, to send an API call to the Convert PDF Colors endpoint, allowing you to effortlessly achieve this color profile conversion.

Converting RGB (Red, Green, Blue) colors to CMYK (Cyan, Magenta, Yellow, Black) is essential for preparing PDF documents for printing. CMYK is the color model used by most printers, and accurately converting RGB colors to CMYK ensures that the printed colors match the intended appearance. This is particularly important for projects like technical manuals, product catalogs, or educational materials where color accuracy is crucial.

Convert PDF from RGB to CMYK with cURL Code Example

curl -X POST "https://api.pdfrest.com/pdf-with-converted-colors" \
  -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=acrobat9-cmyk"

Source: GitHub Repository

Breaking Down the Code

This cURL command sends a POST request to the pdfRest API endpoint for converting PDF colors. Let's break down each part:

curl -X POST "https://api.pdfrest.com/pdf-with-converted-colors"

This line specifies that we are making a POST request to the given URL, which is the endpoint for converting PDF colors.

-H "Accept: application/json"

This header indicates that the client expects a JSON response from the server. JSON is a lightweight data-interchange format that is easy to read and write.

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

This header specifies that the request body will be sent as a multipart form data. This is necessary when uploading files and sending form data in the same request.

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

The API key is used for authenticating the request. Replace the placeholder with your actual API key to authorize the request.

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

This form field uploads the PDF file that you want to convert. Replace /path/to/file with the actual path to your PDF file.

-F "output=example_out"

This form field specifies the desired name of the output file. The converted PDF will be saved with this name.

-F "color_profile=acrobat9-cmyk"

This form field sets the target color profile for the conversion. In this example, the color profile is set to acrobat9-cmyk, which is commonly used for print optimization.

Beyond the Tutorial

In this tutorial, you learned how to use cURL to send a request to the pdfRest API to convert the color profile of a PDF document from RGB to CMYK. This is just one of the many capabilities offered by pdfRest API Tools. We encourage you to explore the full range of tools available in the API Lab.

For more detailed information on each API endpoint, refer to the API Reference Guide. This example demonstrates a multipart API call, but you can also find code samples using JSON payloads at the GitHub Repository.

Generate a self-service API Key now!
Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.