> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/create/thumbnail.md).

# Generate a PDF page thumbnail on Server/Desktop

Create PDF page thumbnails in multiple image formats with this full code sample. Convert PDF to JPG, PNG, BMP, TIFF images using the built-in rasterizer. Explore RAW, BMP, JPEG, PNG, PNG8, TIFF, and T

{% hint style="info" %}
**Requirements**

*These packages are required to use these features in production. Trial keys have unlimited access to all features*

<a href="https://apryse.com/capabilities#PageManipulation" class="button primary">Package: Page Manipulation</a><a href="https://showcase.apryse.com/create-thumbnail" class="button primary">Live demo</a>
{% endhint %}

To create a PDF page thumbnail in multiple image formats.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);
PDFDraw draw = new PDFDraw();

// set the output resolution
draw.SetDPI(92);

// Rasterize the first page in the document and save the result as PNG.
Page pg = doc.GetPage(1);
draw.Export(pg, output_filename, "PNG");
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
PDFDoc doc(filename);
PDFDraw draw;

// set the output resolution 
draw.SetDPI(92);

// Rasterize the first page in the document and save the result as PNG.
Page pg = doc.GetPage(1);
draw.Export(pg, output_filename, "PNG");
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
// use the empty constructor to create a blank PDF
doc := NewPDFDoc(filename)

// set the output resolution 
draw.SetDPI(92)

// Rasterize the first page in the document and save the result as PNG.
pg := doc.GetPage(1)
draw.Export(pg, output_filename, "PNG")
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFDoc doc = new PDFDoc(filename);
PDFDraw draw = new PDFDraw();

// set the output resolution 
draw.setDPI(92);

// Rasterize the first page in the document and save the result as PNG.
Page pg = doc.getPage(1);
draw.export(pg, output_filename, "PNG");
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
async function main() {
  const doc = await PDFNet.PDFDoc.createFromURL(filename);

  // set the output resolution
  const pdfdraw = await PDFNet.PDFDraw.create(92);

  // Rasterize the first page in the document and save the result as PNG.
  const pg = await doc.getPage(1);
  const buf = await pdfdraw.exportStream(pg, 'PNG');

  //optionally save the blob to a file or upload to a server
  const blob = new Blob([buf], { type: 'application/pdf' });
}
PDFNet.runWithCleanup(main);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)
val draw = PDFDraw() 

// set the output resolution
draw.setDPI(92.0)

// Rasterize the first page in the document and save the result as PNG.
val pg = doc.getPage(1)
draw.export(pg, output_filename, "PNG");
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
PTPDFDoc *doc = [[PTPDFDoc alloc] initWithFilepath: filename];

// set the output resolution
PTPDFDraw *draw = [[PTPDFDraw alloc] initWithDpi: 92];

// Rasterize the first page in the document and save the result as PNG.
PTPage* pg = [doc GetPage: 1];
[draw Export:pg filename: output_filename format: @"PNG"];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
let doc: PTPDFDoc = PTPDFDoc(filepath: filename)

// The output resolution is set to 92 DPI
let draw: PTPDFDraw = PTPDFDraw(dpi: 92)

// Rasterize the first page in the document and save the result as PNG.
let pg: PTPage = doc.getPage(1)
draw.export(pg, filename: output_filename, format: "PNG")
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$doc = new PDFDoc($filename);
$draw = new PDFDraw();

// The output resolution is set to 92 DPI.
$draw->SetDPI(92);

// Rasterize the first page in the document and save the result as PNG.
$pg = $doc->GetPage(1);
$draw->Export($pg, $output_filename, "PNG");
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
doc = PDFDoc(filename)
draw = PDFDraw()

# The output resolution is set to 92 DPI.
draw.SetDPI(92)

# Rasterize the first page in the document and save the result as PNG.
pg = doc.GetPage(1)
draw.Export(pg, output_filename, "PNG")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
doc = PDFDoc.new(filename)
draw = PDFDraw.new

# The output resolution is set to 92 DPI.
draw.SetDPI(92)

# Rasterize the first page in the document and save the result as PNG.
pg = doc.GetPage(1)
draw.Export(pg, output_filename, "PNG")
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim doc4 As PDFDoc = New PDFDoc(filename)
Dim draw As PDFDraw = New PDFDraw

' The output resolution is set to 92 DPI.
draw.SetDPI(92)

' Rasterize the first page in the document and save the result as PNG.
Dim pg As Page = doc.GetPage(1)
draw.Export(pg, output_filename, "PNG")
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Convert PDF to image (JPG, PNG, BMP, TIFF)](/core/get-started/samples/converttest.md) Full code sample illustrates how to use the built-in rasterizer in order to render PDF images on the fly and how to save resulting images in PNG and JPEG format. Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.

More image format options:

* **"RAW"** : RAW format.There are four possibilities:
  * `e_rgba` - if transparent and color page;
  * `e_gray_alpha` - if transparent and gray page;
  * `e_rgb` - if opaque and color page;
  * `e_gray` - if opaque and gray page. NOTE that if page is set to be transparent (SetPageTransparent), the output color channels are already multiplied by the alpha channel.
* **"BMP"** : Bitmap image format (BMP)
* **"JPEG"** : Joint Photographic Experts Group (JPEG) image format
* **"PNG"** : 24-bit W3C Portable Network Graphics (PNG) image format
* **"PNG8"** : 8-bit, palettized PNG format. The exported file size should be smaller than the one generated using "PNG", possibly at the expense of some image quality.
* **"TIFF"** : Tag Image File Format (TIFF) image format.
* **"TIFF8"** : Tag Image File Format (TIFF) image format (with 8-bit palete).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/create/thumbnail.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
