How to Convert PDF to PostScript with cURL
This cURL walkthrough uses the public pdfRest API directly from a shell script. It converts a PDF into PostScript through /postscript with visible output controls for a production workflow. The complete sample is included below so cURL developers can see the file handling, request construction, and response path together.
Why PDF to PostScript with cURL?
Shell automation is a practical fit when an existing print or prepress stage accepts PostScript but the upstream system delivers PDFs. The /postscript request turns that transition into a scriptable processing step.
For example, a release job can convert an approved PDF to Level 3 PostScript and place it in a watched production directory. Page range and scaling switches can be stored next to the job rather than relying on manual print-dialog choices.
That keeps the original PDF intact while producing a distinct PostScript resource for the downstream stage. The response identifies that new result without requiring the script to guess its filename or location.
cURL Code Example for PDF to PostScript
#!/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 PDF to PostScript through multipart /postscript. # Pairing this endpoint with /pdf creates a PDF -> PostScript -> PDF workflow commonly # called PDF refrying. Some print and prepress workflows use it to rebuild, flatten, or # normalize page content, but the lossy roundtrip can discard PDF-specific features. # These settings request Level 3, text-safe output, all pages at original scale, # shrink-to-fit without rotation, and printable annotations. INPUT_PATH="/path/to/sample.pdf" curl --location "$API_URL/postscript" \ --header "Accept: application/json" \ --header "Content-Type: multipart/form-data" \ --header "Api-Key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \ --form "file=@$INPUT_PATH;type=application/pdf" \ --form "ps_level=3" \ --form "page_range=all" \ --form "binary_output=false" \ --form "scale=1" \ --form "rotate=false" \ --form "shrink_to_fit=true" \ --form "print_annotations=true" \ --form "output=postscript_from_pdf"
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 PDF to PostScript example, cURL sends the multipart request to /postscript. 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.
Select PostScript Output Settings
--header "Content-Type: multipart/form-data" \ --header "Api-Key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \ --form "file=@$INPUT_PATH;type=application/pdf" \ --form "ps_level=3" \ --form "page_range=all" \ --form "binary_output=false" \ --form "scale=1" \ --form "rotate=false" \ --form "shrink_to_fit=true" \ --form "print_annotations=true" \ --form "output=postscript_from_pdf"
The cURL sample explicitly requests ps_level=3, all pages, binary output, no rotation, unit scale, shrink-to-fit, and printable annotations. Those choices describe the new PostScript result; they do not edit or replace the uploaded PDF.
Build the multipart request
--header "Content-Type: multipart/form-data" \ --header "Api-Key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \ --form "file=@$INPUT_PATH;type=application/pdf" \ --form "ps_level=3" \ --form "page_range=all" \ --form "binary_output=false" \ --form "scale=1" \ --form "rotate=false" \ --form "shrink_to_fit=true" \ --form "print_annotations=true" \ --form "output=postscript_from_pdf"
For the PDF to PostScript 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
# shrink-to-fit without rotation, and printable annotations. INPUT_PATH="/path/to/sample.pdf" curl --location "$API_URL/postscript" \ --header "Accept: application/json" \ --header "Content-Type: multipart/form-data" \ --header "Api-Key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \ --form "file=@$INPUT_PATH;type=application/pdf" \ --form "ps_level=3" \ --form "page_range=all" \ --form "binary_output=false" \ --form "scale=1" \
After the PDF to PostScript 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
This cURL example submitted a PDF to /postscript and selected the controls that shape the resulting PostScript file. Retain the returned resource ID whenever the output needs to be downloaded, monitored, or used by a following workflow step.
Try representative pdf to postscript inputs in API Lab. For the authoritative request fields, accepted values, and response contract, consult the pdfRest API Reference Guide. The same request pattern can then be adapted to your cURL application’s error handling, retention policy, and delivery workflow.
For cURL applications that already hold the source as a managed resource, the repository includes a JSON-payload PDF-to-PostScript example. It uploads the PDF separately and sends the returned ID with the PostScript options. View the JSON-payload sample on GitHub.