Skip to main content

POST /v1/pdf/convert/to/webp

WEBP is an image format invented by Google and is supported by Google Chrome and other modern browsers. It provides good quality with smaller file sizes.

Attributes

Attributes are case-sensitive and should be inside JSON for POST request. for example: { "url": "https://example.com/file1.pdf" }
AttributeTypeRequiredDefaultDescription
urlstringYes-URL to the source file url attribute
callbackstringNo-The callback URL (or Webhook) used to receive the POST data. see Webhooks & Callbacks. This is only applicable when async is set to true.
httpusernamestringNo-HTTP auth user name if required to access source URL.
httppasswordstringNo-HTTP auth password if required to access source URL.
pagesstringNoall pagesSpecify page indices as comma-separated values or ranges to process (e.g. “0, 1, 2-” or “1, 2, 3-7”). The first-page index is 0. Use ”!” before a number for inverted page numbers (e.g. “!0” for the last page). If not specified, the default configuration processes all pages. The input must be in string format.
rectstringNo-Defines coordinates for extraction. UsePDF Edit Add Helperto get or measure PDF coordinates. The format is {x} {y} {width} {height}.
langstringNoengSet the language for OCR (text from image) to use for scanned PDF, PNG, and JPG documents input when extracting text. see Language Support. You can also use 2 languages simultaneously like this: eng+deu (any combination).
inlinebooleanNofalseSet to true to return results inside the response. Otherwise, the endpoint will return a URL to the output file generated.
passwordstringNo-Password for the PDF file.
asyncbooleanNofalseSet async to true for long processes to run in the background, API will then return a jobId which you can use with the Background Job Check endpoint. Also see Webhooks & Callbacks
namestringNo-File name for the generated output, the input must be in string format.
expirationintegerNo60Set the expiration time for the output link in minutes. After this specified duration, any generated output file(s) will be automatically deleted from PDF.co Temporary Files Storage. The maximum duration for link expiration varies based on your current subscription plan. To store permanent input files (e.g. re-usable images, pdf templates, documents) consider using PDF.co Built-In Files Storage.
profilesobjectNo-See Profiles for more information.
    outputDataFormatstringNo-If you require your output as base64 format, set this to base64
    RenderTextObjectsbooleanNotrueControls whether to render text objects in the PDF document. When set to true, it will render all text objects in the PDF document. Set to false to skip over text objects during rendering. See Disable Text Layer for more information.
    RenderingResolutionintegerNo120See Set Image Resolution for more information.
    RenderImageObjectsbooleanNotrueRender image objects or not
    RenderVectorObjectsbooleanNotrueRender vector objects or not
    WEBPQualityintegerNo75See profiles.WEBPQuality
    DataEncryptionAlgorithmstringNo-Controls the encryption algorithm used for data encryption. See User-Controlled Encryption for more information. The available algorithms are: AES128, AES192, AES256.
    DataEncryptionKeystringNo-Controls the encryption key used for data encryption. See User-Controlled Encryption for more information.
    DataEncryptionIVstringNo-Controls the encryption IV used for data encryption. See User-Controlled Encryption for more information.
    DataDecryptionAlgorithmstringNo-Controls the decryption algorithm used for data decryption. See User-Controlled Encryption for more information. The available algorithms are: AES128, AES192, AES256.
    DataDecryptionKeystringNo-Controls the decryption key used for data decryption. See User-Controlled Encryption for more information.
    DataDecryptionIVstringNo-Controls the decryption IV used for data decryption. See User-Controlled Encryption for more information.

Disable Text Layer

We can turn off the text layer for our render as follows:
{
 "profiles": "{ 'RenderTextObjects': false }"
}

Set Image Resolution

By default the screen resolution is 120 DPI. To change the rendering resolution, please use:
{
 "profiles": "{ 'RenderingResolution': 300 }"
}

profiles.WEBPQuality

To control the quality and encoding speed use the following:
{
 "profiles": "{ 'WEBPQuality': 75 }"
}

Use this parameter to set additional configurations for fine-tuning and extra options. Explore the Profiles section for more.

Profiles section for more.
"profiles":
 {
   'RenderTextObjects': false,
   'RenderVectorObjects': true,
   'RenderImageObjects': true
 }

OCRImagePreprocessingFilters

To set image preprocessing filters, please use:
{
 "profiles": "{
    "OCRImagePreprocessingFilters.AddGrayscale()": [],
    "OCRImagePreprocessingFilters.AddGammaCorrection()": [
        1.4
    ]
}"
}

Query parameters

No query parameters accepted.

Responses

ParameterTypeDescription
urlsarray[string]List of URLs to the final PDF file stored in S3.
outputLinkValidTillstringTimestamp indicating when the output link will expire
pageCountintegerNumber of pages in the PDF document.
errorbooleanIndicates whether an error occurred (false means success)
statusstringStatus code of the request (200, 404, 500, etc.). For more information, see Response Codes.
namestringName of the output file
creditsintegerNumber of credits consumed by the request
remainingCreditsintegerNumber of credits remaining in the account
durationintegerTime taken for the operation in milliseconds

Example Payload

To see the request size limits, please refer to the Request Size Limits.
{
  "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-image/sample.pdf",
  "inline": true,
  "pages": "0-",
  "async": false
}

Example Response

To see the main response codes, please refer to the Response Codes page.
{
  "urls": [
    "https://pdf-temp-files.s3.amazonaws.com/c15b8d82e0034d01a73eac719d69349b/sample.png",
    "https://pdf-temp-files.s3.amazonaws.com/152d2fe414b645e38f81a49e5dafa85b/sample.png"
  ],
  "pageCount": 2,
  "error": false,
  "status": 200,
  "name": "sample.png",
  "duration": 1121,
  "remainingCredits": 98722216,
  "credits": 30
}
Inconsistent URL Encoding in cURL Output: When using cURL to make API requests, the output JSON may show URL characters encoded as Unicode escape sequences. For example, the ampersand character (&) may appear as \u0026 in the cURL output. This is normal JSON encoding behavior and does not affect the validity of the URL. The URL will function correctly when used, as JSON parsers automatically decode these escape sequences. If you’re parsing the response programmatically, your JSON parser will handle this conversion automatically.

Code Samples

curl --location --request POST 'https://api.pdf.co/v1/pdf/convert/to/png' \
--header 'x-api-key: *******************' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-image/sample.pdf",
"inline": true,
"pages": "0-",
"async": false
}'