---
title: "imagesToPdf"
version: "0.9.0"
url: "https://docs.laminapdf.com/reference/sdk/functions/imagestopdf/"
---

# imagesToPdf

```ts
function imagesToPdf(images, options?): Document;
```

Defined in: [packages/sdk/src/builder.ts:1285](https://github.com/laudebugs/laminapdf/blob/v0.9.0/packages/sdk/src/builder.ts#L1285)

A new document with one page per image, in order. Needs the extract or the text module
(`loadExtract()`, or `init({ text: true })`). A JPEG is embedded as it is, without
decoding it; a PNG keeps its transparency; each image is drawn the way up its EXIF orientation
says.

## Parameters

### images

readonly [`Image`](/reference/sdk/classes/image.md)[]

the pages' images, at least one.

### options?

[`ImagesToPdfOptions`](/reference/sdk/interfaces/imagestopdfoptions.md) = `{}`

the page size to fit them in, the margin, the default resolution, and the
file ID, producer and creation date.

## Returns

[`Document`](/reference/sdk/classes/document.md)

## Example

```ts
using doc = imagesToPdf([Image.jpeg(photo)], { fit: "A4", margin: 42 });
const pdf = doc.save();
```

## Throws

[LaminaPdfError](/reference/sdk/classes/laminapdferror.md) `not-initialized`; `extract-module-not-loaded` when neither the
extract nor the text module is loaded; `invalid-geometry` for no images, a negative
margin or resolution, or a page too small for its margins; `unknown-option`,
`invalid-argument`.

## Since

0.3.0
