How to Convert PostScript to PDF with cURL

Convert PostScript (.ps) files to PDF with cURL and an optional Distiller-compatible .joboptions profile.
Share this page

This cURL walkthrough uses the public pdfRest API directly from a shell script. It converts a PostScript (.ps) file into PDF through the pdfRest Convert to PDF API Tool and includes a custom .joboptions profile. The complete sample is included below so cURL developers can see the file handling, request construction, and response path together.

Why PostScript to PDF with cURL?

Build scripts and print-production jobs often produce a .ps file even when the next recipient expects PDF. A compact cURL request can bridge that boundary without adding desktop conversion software to the build host.

A packaging pipeline might render a PostScript proof, apply its established .joboptions profile, and store the returned PDF where an approval system can retrieve it. The profile stays versionable alongside the pipeline configuration.

The shell form makes the source and optional profile explicit, so operators can switch between the default conversion settings and a known project profile without changing the API endpoint.

cURL Code Example for PostScript to PDF

#!/bin/sh

# By default, we use the US-based API service. This is the primary endpoint for global use.
API_URL="https://api.pdfrest.com"

# For GDPR compliance and enhanced performance for European users, you can switch to the EU-based service by uncommenting the URL below.
# For more information visit https://pdfrest.com/pricing#how-do-eu-gdpr-api-calls-work
# API_URL="https://eu-api.pdfrest.com"

# This sample converts a PostScript (.ps) file to PDF with a custom .joboptions profile.
# A .joboptions file contains Adobe Distiller-compatible conversion settings. The
# profile is optional; omit job_options to use default settings. pdfRest applies a
# supplied profile with Datalogics PDF Converter SDK. Datalogics maintains the SDK
# in partnership with Adobe, using the same Adobe technology that powers Distiller.
# Pairing this /pdf call with /postscript creates a PDF -> PostScript -> PDF workflow
# commonly called PDF refrying. Some print and prepress workflows use it to rebuild or
# normalize page content, but the lossy roundtrip can discard PDF-specific features.
INPUT_PATH="/path/to/sample.ps"
JOB_OPTIONS_PATH="/path/to/custom.joboptions"

curl --location "$API_URL/pdf" \
  --header "Accept: application/json" \
  --header "Content-Type: multipart/form-data" \
  --header "Api-Key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  --form "file=@$INPUT_PATH;type=application/postscript" \
  --form "job_options=@$JOB_OPTIONS_PATH;type=application/octet-stream" \
  --form "output=pdf_from_postscript"

Source: View the sample on GitHub

Breaking Down the Code

Configure the service and input

# By default, we use the US-based API service. This is the primary endpoint for global use.
API_URL="https://api.pdfrest.com"

# For GDPR compliance and enhanced performance for European users, you can switch to the EU-based service by uncommenting the URL below.
# For more information visit https://pdfrest.com/pricing#how-do-eu-gdpr-api-calls-work
# API_URL="https://eu-api.pdfrest.com"

For this PostScript to PDF example, cURL sends the multipart request to /pdf. cURL needs no language package installation. The sample keeps the service URL, API key, input path, and output name together near the top of the shell script so those values can be replaced before the request is sent. The sample’s placeholder path and API key make the moving pieces visible; replace them with a real local path and protected runtime credential before using the request.

Apply the PostScript Conversion Profile

--header "Content-Type: multipart/form-data" \
  --header "Api-Key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  --form "file=@$INPUT_PATH;type=application/postscript" \
  --form "job_options=@$JOB_OPTIONS_PATH;type=application/octet-stream" \
  --form "output=pdf_from_postscript"

Here, cURL sends the PostScript source and the optional profile as separate files. A .joboptions file contains Adobe Distiller-compatible conversion settings; pdfRest applies a supplied profile with Datalogics PDF Converter SDK, maintained in partnership with Adobe and using the same Adobe technology that powers Distiller. Omitting job_options uses default settings.

Build the multipart request

--header "Content-Type: multipart/form-data" \
  --header "Api-Key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  --form "file=@$INPUT_PATH;type=application/postscript" \
  --form "job_options=@$JOB_OPTIONS_PATH;type=application/octet-stream" \
  --form "output=pdf_from_postscript"

For the PostScript to PDF form, each --form option creates one multipart field. cURL reads file fields from disk when their value begins with @, while ordinary quoted values become text fields.

Read the output resource

INPUT_PATH="/path/to/sample.ps"
JOB_OPTIONS_PATH="/path/to/custom.joboptions"

curl --location "$API_URL/pdf" \
  --header "Accept: application/json" \
  --header "Content-Type: multipart/form-data" \
  --header "Api-Key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  --form "file=@$INPUT_PATH;type=application/postscript" \
  --form "job_options=@$JOB_OPTIONS_PATH;type=application/octet-stream" \
  --form "output=pdf_from_postscript"

After the PostScript to PDF call, the command prints the JSON response. Read outputId to retain the generated resource for a later call or download it from the returned URL before the service retention period ends.

Beyond the Tutorial

You have now used cURL to turn a PostScript source into a managed PDF and make its conversion profile explicit. That gives the surrounding application a deliberate choice between a team-maintained .joboptions file and the service defaults.

Try representative postscript to pdf inputs in API Lab. For the authoritative request fields, accepted values, and response contract, consult the Convert to PDF API Tool documentation. The same request pattern can then be adapted to your cURL application’s error handling, retention policy, and delivery workflow.

A JSON-payload PostScript-to-PDF example is available for cURL as well. That form uploads the .ps and optional .joboptions files first, then passes their resource IDs to /pdf. View the JSON-payload sample on GitHub.

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