Free plan

Document Preview

Make a picture of the first page of a document
POST
/v1/documents/preview

About this tool

This tool turns pages of a document into pictures, so you can see them without opening the file. By default it makes the first page only. You can ask for other pages or all pages, and choose the picture width and type. It works with PDF, Word, Excel, PowerPoint and similar files.
For example, you want a small thumbnail of the first page of each report to put in a list.

How to use it

  1. Choose this tool.
  2. Add your document with Upload or drag and drop.
  3. Choose which pages you want, such as first, all or 1-3.
  4. Press Generate.
  5. Download the picture or pictures.

What you get back

You get one picture per page, as PNG, JPEG or WebP files you can download.
TEST IT LIVE

Try Document Preview in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Documents
Plan
Free
Method
POST
Endpoint
/v1/documents/preview
Tool ID
documents.preview
Authentication
API key
Accepts
PDF, DOCX, XLSX, PPTX, ODT, ODS +25 more
Background jobs
Yes
Usage group
Documents
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/documents/preview" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'file=@document.pdf' \
  -F 'width=400' \
  -F 'format=png' \
  -F 'dpi=1'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.documents.preview({
    "file": 'document.pdf',
    "width": 400,
    "format": "png",
    "dpi": 1
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->documents()->preview([
    'file' => 'document.pdf',
    'width' => 400,
    'format' => 'png',
    'dpi' => 1,
]);
echo $result->requestId;
FAQ

Frequently asked questions

Render pages of any supported document as images (through PDF): the first page by default, or the pages you ask for.

Document Preview accepts PDF, DOCX, XLSX, PPTX, ODT, ODS, ODP, RTF, EPUB, TXT, MD, HTML and 19 more. You can send several files in one request.

Document Preview is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/documents/preview with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.