How to Convert PDF to BMP with cURL

Learn how to create BMP image files of PDF pages using PDF to Images API Tool by pdfRest with cURL
Share this page

Why Convert PDF to BMP with cURL?

The pdfRest PDF to Images API Tool is a powerful resource that allows users to convert PDF documents into image files. This tutorial will demonstrate how to send an API call to the PDF to Images endpoint using cURL, a command-line tool for transferring data with URLs. The API is designed to be simple and efficient, making it accessible for developers to integrate PDF to image conversion into their applications or workflows.

There are many scenarios where converting a PDF to images could be useful. For instance, a web developer might need to display the content of a PDF on a website without relying on the user's PDF reader. Alternatively, an archivist could use this tool to convert scanned documents stored as PDFs into image files for easier viewing and sharing. The ability to automate this process through an API call can significantly streamline such tasks.

Convert PDF to BMP with cURL Code Example

curl -X POST "https://api.pdfrest.com/bmp" \
  -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"

Reference to the provided code: pdfRest API Samples on GitHub.

Breaking Down the Code

This section will explain the different components of the cURL command used to call the PDF to Images API:

-X POST

This specifies the HTTP method for the request, which is POST in this case, indicating that data will be sent to the server.

"https://api.pdfrest.com/bmp"

This is the endpoint URL that specifies the API's PDF to Images service for converting PDFs to BMP image files.

-H "Accept: application/json"

This header tells the server that the client expects a response in JSON format.

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

This header indicates that the data being sent in the request is in multipart form-data format, which is used for uploading files.

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

This header provides the API key required for authentication with the pdfRest service. The 'xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' is a placeholder for the actual API key.

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

This form field is used to upload the PDF file to be converted. The '@' symbol indicates that a file is being uploaded, followed by the path to the PDF file on the local system.

-F "output=example_out"

This form field specifies the prefix for the output file(s). The API will generate image files with this prefix followed by a page number and the appropriate file extension.

Beyond the Tutorial

This tutorial has walked you through the process of using cURL to call the pdfRest PDF to Images API to convert a PDF file into image files. By understanding the structure of the API call and the purpose of each component, you can adapt this example to fit your specific needs.

Feel free to explore and demo all of the pdfRest API Tools in the API Lab, and for more detailed information, consult the API Reference Guide.

Note: This is an example of a multipart API call. Code samples using JSON payloads can be found at pdfRest API Samples on 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