English
  1. Home
  2. Page
  3. PdfToImage

PdfToImage

Convert specified PDF page to image

copy
Something went wrong, try again
copy
            
                    
        
Body parameter
Parameter VALUE DESCRIPTION

pdfPageToImageRequest

Required

copy
PdfPageToImageRequest Convert PDF-page to Image
PdfPageToImageRequest
Parameter VALUE DESCRIPTION

Format

Required

PageExportFormat Image file format

Height

Required

int32 The converted image height. Default is PDF page height

PageNumber

Required

int32 Number of PDF file page. Starts with 1. Default is 1

PdfBase64File

Required

close-icon
string Base64 encoded PDF document to process

Width

Required

int32 The converted image width. Default is PDF page width
copy Copy to clipboard
        
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.documentize.cloud/page/to-image"
  method := "POST"

  payload := strings.NewReader(`{
      "Format": "Jpeg",
      "PageNumber": 1,
      "Width": 1,
      "Height": 1,
      "PdfBase64File": "Base64 encoded file...",
    }`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
                   
         
            
File file = new File("path/to/file/fileName.pdf");
byte[] encoded = Base64.encodeBase64(FileUtils.readFileToByteArray(file));
String base64EncodedFile = new String(encoded, StandardCharsets.US_ASCII);

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, 
    "{" +
      "\"Format\": \"Jpeg\"," +
      "\"PageNumber\": 1," +
      "\"Width\": 1," +
      "\"Height\": 1," +
      "\"PdfBase64File\": \"" + base64EncodedFile + "\"," +
    "}");

Request request = new Request.Builder()
  .url("https://api.documentize.cloud/page/to-image")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .build();

Response response = client.newCall(request).execute();
                   
        
            
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.documentize.cloud/page/to-image',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
      "Format": "Jpeg",
      "PageNumber": 1,
      "Width": 1,
      "Height": 1,
      "PdfBase64File": "Base64 encoded file...",
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                   
        
            
import requests
import json

url = "https://api.documentize.cloud/page/to-image"

json_data = json.dumps({
      "Format": "Jpeg",
      "PageNumber": 1,
      "Width": 1,
      "Height": 1,
      "PdfBase64File": "Base64 encoded file...",
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=json_data)

print(response.text)
                   
        
            
curl --location --request POST 'https://api.documentize.cloud/page/to-image' \
--header 'Content-Type: application/json' \
--data-raw '{
      "Format": "Jpeg",
      "PageNumber": 1,
      "Width": 1,
      "Height": 1,
      "PdfBase64File": "Base64 encoded file...",
}'
                   
        
            
require "uri"
require "json"
require "net/http"

url = URI("https://api.documentize.cloud/page/to-image")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = JSON.dump({
      "Format": "Jpeg",
      "PageNumber": 1,
      "Width": 1,
      "Height": 1,
      "PdfBase64File": "Base64 encoded file...",
})

response = https.request(request)
puts response.read_body

                   
        
            
var client = new RestClient("https://api.documentize.cloud/page/to-image");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
var body = "{" + 
      "\"Format\": \"Jpeg\"," +
      "\"PageNumber\": 1," +
      "\"Width\": 1," +
      "\"Height\": 1," +
      "\"PdfBase64File\": \"" + base64EncodedFile + "\"," +
"}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
                       
            
Overview

About Convert Page to Image Method

This page provides detailed, step-by-step instructions on how to effectively utilize our cloud-based API to convert any page of your PDF files into an image in multiple programming languages, including Go, Java, PHP, Python, Curl, Ruby, and C#. Our Document API's "To-Image" method makes the conversion process easy and efficient. You can specify the page number to be converted using parameters, or simply leave it blank to convert the default first page of the PDF document. Additionally, you have the flexibility to set the height and width of the image, as well as choose the desired output file format. Experience seamless PDF to image conversion with our powerful API, tailored to meet your diverse requirements.


Programming languages the API is compatible with

The API uses the REST protocol, making it compatible with a wide range of programming languages, including but not limited to: Go, Java, PHP, Python, Curl, Ruby, C#.

Easy to use

Our API Reference and Guide are designed to be user-friendly and easy to follow, providing all the necessary information for a quick start. Furthermore, our API Libraries are accompanied by their own documentation, making integration into your application seamless. With our comprehensive resources, you can efficiently utilize our API to meet your specific requirements.

Secure

At our company, we place a high priority on your security and privacy. To protect your private data, we never store it in our environment and offer isolated options. We understand the importance of keeping your information safe and take all necessary measures to ensure that it remains secure.
Convert Page to Image
clock
Add a File
To ensure smooth and accurate file processing and conversion page from your PDF file into image using the "To-Image" method (Page API), it is essential to verify that the file you are working with matches the one specified in the method. This ensures that the page convertion is applied correctly to the intended PDF file, ensuring a successful outcome and preserving the integrity of your document.
arrow
clock
Run the Code
To run the code, copy and paste it into a file and execute it from the same directory where you added the necessary files. For further details, refer to our language-specific guides on how to get started.
arrow
clock
View the Result
To view the results of the "To-Image" method (Page API), you can easily open the file received as the output, which should be located in your project folder. If you choose to utilize the "To-Image" method online to convert page from your PDF file into image, the process will automatically generate a PDF file with the converted pages, which will be conveniently downloaded for you to access.
clock
How long does it takes to convert page from PDF file into Image using "To-Image" method (Page API)?
Our Page API, specifically the "To-Image" method, is designed to provide efficient and speedy file processing. With our service, you can expect rapid results, often delivered within a matter of seconds. Experience the speed and efficiency of our API, enabling you to quickly convert page from your PDF file into image and streamline your workflow for optimal productivity.
clock
It is safe to use "To-Image" method (Page API)?
We prioritize the security and privacy of your data. As a company, we take comprehensive measures to ensure the security of your information. We do not store any files that you submit to us for processing, and they are processed solely to provide you with the desired results. Your security and privacy are of the utmost importance to us and we take every precaution to protect your data throughout the entire process. You can trust us to handle your files with the utmost care and professionalism.
clock
What output can I expect from the "To-Image" method (Page API)?
The "To-Image" method (Page API) allows you to convert any specific page from your PDF document into an image. You have the flexibility to customize the output file parameters such as height, width, and format. If you do not specify a page number, by default, the first page of the document will be converted. It's important to note that the program counts the physical pages, not the page numbers on them. For example, if you start numbering from the second page and label it as "1", the first unnumbered page will always be considered as the first page for conversion purposes.
clock
How does method “To-Image” (Page API) works?
The "ToImage" method (Page API) provides a simple and efficient way to convert a page from a PDF file into an image. Our user-friendly and seamless process allows you to effortlessly upload your file, click the "POST" button, and await the results. In just a few seconds, you'll receive a file with the converted page in image format. If you wish to integrate this method into your project, you can easily copy and use the provided code examples in the programming language of your choice for smooth integration.
FAQ

Frequently Asked Questions

We encourage you to review our Frequently Asked Questions (FAQ) section for answers to common inquiries. If you do not find the information you need, our dedicated support service is readily available to assist you with any additional questions or concerns. Don't hesitate to reach out for further assistance.