---
title: "Generate an image of to provided pdf file"
method: POST
path: "/api/v1/pdf/pdftoimage"
tags: ["Pdf"]
---

# Generate an image of to provided pdf file

`POST /api/v1/pdf/pdftoimage`

## Request body

- PdfToImageRequestDto
  - `pdfFileBase64String` string, nullable — The pdf file to generate image from, as Base64 encoded string.
  - `options` PdfToImageOptions
    - `pageNumber` integer — Which page of the pdf file to generate image from, default is first page
    - `imageFormat` string, nullable — Valid options are "image/jpeg", "image/png" or "image/gif". Default is "image/png"
    - `horizontalResolution` number, double — Set the horizontal resolution, default is 96 dpi;
    - `verticalResolution` number, double — Set the vertical resolution, default is 96 dpi;
    - `width` integer — Set the width of the output image, default value is width of source document. To scale width, and keeping proportions, do not set height;
    - `height` integer — Set the height of the output image, default value is width of source document. To scale height, and keeping proportions, do not set width;
    - `transparent` boolean — Keep the background of the image transparent. This setting is not available in JPEG-files, since transparency is not supported in the JPEG format.
    - `jpegQuality` integer — Sets the quality of jpeg images, range 0 to 100, default is 75
    - `pngCompressionLevel` integer — Sets the png compression level, range 1 - 9, default is 6

## Response `200`

Generate an image of the provided pdf file. Either the image file directly or serialized as Json if Accept-header is set to application/json

- ImageResponseDto — When setting the Accept-header in the request to "application/json" the image file will be return as Base64 encoded string. Note that converting data to Base64 encoded strings increases the response size with approximately 33%, if you can accept the a binary format it's better to use Accept-header "image/jpeg", "image/png" or "image/gif".
  - `errorMessage` string, nullable — If any error occurs the message will be displayed in here
  - `imageBase64String` string, nullable — The Base64 encoded string that is the image file. This is a complete data uri, including media type that can be used directly as src on a img-tag e.g.

## Other responses

- `400` — If any error occurs parsing input
- `415` — If content-type of request is not set to multipart/form-data or application/json
- `429` — If you reach the monthly request limit for your subscription plan

---

[API](https://skmtc.net/pdfbroker/apis/pdfbroker-io-api.md) · [All operations](https://skmtc.net/pdfbroker/apis/pdfbroker-io-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pdfbroker/pdfbroker-io-api/versions/c10982b50857/schema)
