pdf-image
![](/img/dynamic-pdf-cloud-api-logo-light-small.png)
The pdf-image
endpoint takes an HTTP POST form submission, where a PDF is sent as multipart/form-data. The PDF is then rasterized into one or more images and returned from the endpoint.
POST https://api.dpdf.io/v1.0/pdf-image HTTP/1.1
Authorization: Bearer DP.xxx-api-key-xxx
A single-page PDF rasterizes into a single image which is returned as a byte-array. A multi-page PDF returns a JSON document where each rasterized image is converted to base64 and returned in the JSON document.
Refer to pdf-image in the Client Libraries section of the Users Guide for this endpoint using the DynamicPDF API's client libraries.
Request/Response
Request | Request Data |
---|---|
POST | Form |
Response | Response Type | |
---|---|---|
The expected image format and the image as binary. | image/image-type | image/png, image/tiff, image/bmp, etc. |
-OR- | ||
A JSON document containing array of base64 encoded images. | application/json |
A PDF can have multiple pages. If the PDF consists of a single page, then the image is returned as a byte-array. If the PDF consists of multiple pages, then each image is returned as a base64 encoded string in a JSON document.
{
"images": [
"base64string image data page1",
"base64string image data page2",
"base64string image data page3"
],
"contentType": "image/png"
}
Parameters
Parameters | Type | Description | Abbreviated | Default |
---|---|---|---|---|
Header | ||||
Authorization | Bearer DP.V9xxxx | The API key used to authenticate endpoint. | ||
Content-Type | application/pdf | The PDF content type. | ||
Form Field | ||||
pdf | multipart/form-data | The PDF document. | ||
URL | ||||
startPageNumber | 1..n | sp | 1 | |
pageCount | 1..n | pc | 0 (prints all pages) | |
imageFormat | jpeg | gif | bmp | png | tiff | if | png | |
quality | 1..100 | qt | 60 | |
ditheringPercent | 1..100 | dp | 25 | |
ditheringAlgorithm | floydSteinberg | bayer | none | da | floydSteinberg | |
colorFormat | rgb | monochrome | indexd | cf | rgb | |
multiPage | true | false | mp | false | |
blackThreshold | 0..255 | bt | na | |
quantizationAlgorithm | octree | webSafe | werner | wu | qa | octree | |
imageSize | dpi | fixed | max | percentage | - | dpi | |
horizontalDpi | 0..n | hd | 96 | |
verticalDpi | 0..n | vd | 96 | |
height | 0..n | ht | na | |
width | 0..n | wd | na | |
unit | millimeter | inch | point | ut | point | |
maxHeight | 0..n | mh | na | |
maxWidth | 0..n | mw | na | |
horizontalPercentage | 1..100 | hp | 100 | |
verticalPercentage | 1..100 | vp | 100 |
Example Request/Response
The following example illustrates calling the pdf-image
endpoint using a single-page PDF followed by a multi-page PDF.
Single Image
A PDF consisting of a single page returns a binary-array.
Example Request
curl https://api.dpdf.io/v1.0/pdf-image
-H"Authorization:Bearer DP--api-key--"
-F "pdf=@C:/temp/dynamicpdf-api-samples/pdf-image/onepage.pdf"
-o simple-image.png
Example Response
Multiple Images
A PDF consisting of multiple pages results in a JSON document where each rasterized page is a base64 encoded string.
Example Request
curl https://api.dpdf.io/v1.0/pdf-image
-H"Authorization:Bearer DP--api-key--"
-F "pdf=@C:/temp/dynamicpdf-api-samples/pdf-image/multipage.pdf"
-o images.json
Example Response
{
"images":["--snip--","--snip--"],
"contentType":"image/png"
}
Use the startPage
and pageCount
query string parameters to extract a single-page from a multi-page PDF. For example, the following cURL command extracts and converts only the second page from the PDF in the previous example.
curl "https://api.dpdf.io/v1.0/pdf-image?sp=2&pc=1"
-H"Authorization:Bearer DP--api-key--"
-F "pdf=@C:/temp/dynamicpdf-api-samples/pdf-image/multipage.pdf"
-o simple-image.png
Further Information
You can also use one of DynamicPDF's provided client libraries to integrate the endpoints into your client applications if you prefer. For more information, refer to the relevant Users Guide sections:
- DynamicPDF API's Endpoints - (cloud-api-overview), and
- DynamicPDF API's Client Libraries - (cloud-api-client-libraries).