# PdfExport

## Content

# Namespace: PdfExport

## Table of contents

### Type aliases

- [CheckCancelCallback](PdfExport#checkcancelcallback)
- [DocumentSecurity](PdfExport#documentsecurity)
- [OnProgressCallback](PdfExport#onprogresscallback)
- [PdfExportResult](PdfExport#pdfexportresult)
- [PdfFontDescriptor](PdfExport#pdffontdescriptor)
- [PdfSettings](PdfExport#pdfsettings)
- [PdfSettingsInfo](PdfExport#pdfsettingsinfo)
- [PdfVersion](PdfExport#pdfversion)
- [Permissions](PdfExport#permissions)

### Functions

- [exportDocument](PdfExport#exportdocument)

## Type aliases

### <a id="checkcancelcallback" name="checkcancelcallback"></a> CheckCancelCallback

Ƭ **CheckCancelCallback**: () => `boolean`

#### Type declaration

▸ (): `boolean`

Defines a callback that determines whether export should be canceled.

**`example`**
```ts
const shouldCancel: CheckCancelCallback = () => false;
```

##### Returns

`boolean`

`true` to cancel the export; otherwise, `false`.

___

### <a id="documentsecurity" name="documentsecurity"></a> DocumentSecurity

Ƭ **DocumentSecurity**: `Object`

Represents document security settings.

**`example`**
```ts
const security: DocumentSecurity = {
	userPassword: 'secret',
	permissions: { printing: 'lowResolution' },
};
```

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `ownerPassword?` | `string` | Gets or sets the owner password used to enforce permissions. |
| `permissions?` | [`Permissions`](PdfExport#permissions) | Gets or sets the document permissions. |
| `userPassword?` | `string` | Gets or sets the user password used to open the document. |

___

### <a id="onprogresscallback" name="onprogresscallback"></a> OnProgressCallback

Ƭ **OnProgressCallback**: (`pageNumber`: `number`) => `void`

#### Type declaration

▸ (`pageNumber`): `void`

Defines a callback invoked after each page is rendered.

**`example`**
```ts
const onProgress: OnProgressCallback = (pageNumber) => console.log(pageNumber);
```

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `pageNumber` | `number` | The one-based page number that has finished rendering. |

##### Returns

`void`

___

### <a id="pdfexportresult" name="pdfexportresult"></a> PdfExportResult

Ƭ **PdfExportResult**: `Object`

Represents the result of a PDF export.

**`example`**
```ts
const result: PdfExportResult = {
	data: new Blob(),
	download: (name) => console.log(name),
};
```

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `data` | `Blob` | Gets or sets the exported content. |
| `download` | (`filename?`: `string`) => `void` | Gets or sets the function that triggers a browser download of the export result.  **`example`** ```ts const result = {} as PdfExportResult; result.download('report.pdf'); ``` |

___

### <a id="pdffontdescriptor" name="pdffontdescriptor"></a> PdfFontDescriptor

Ƭ **PdfFontDescriptor**: `Object`

Represents a PDF font descriptor.

**`example`**
```ts
const font: PdfFontDescriptor = {
	name: 'Roboto',
	source: '/fonts/roboto.woff2',
	weight: '400',
};
```

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `name` | `string` | Gets or sets the font name. |
| `postscriptName?` | `string` | Gets or sets the font PostScript name. |
| `source` | `string` \| `string`[] | Gets or sets the font source. |
| `style?` | `string` | Gets or sets the font style. |
| `useAsDefault?` | `boolean` | Gets or sets a value indicating whether this font is the default. |
| `weight?` | `string` | Gets or sets the font weight. |

___

### <a id="pdfsettings" name="pdfsettings"></a> PdfSettings

Ƭ **PdfSettings**: `Object`

Represents PDF export settings.

**`example`**
```ts
const settings: PdfSettings = {
	pdfVersion: '1.7',
	autoPrint: false,
};
```

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `autoPrint?` | `boolean` | Gets or sets whether the document prints on open. |
| `fonts?` | [`PdfFontDescriptor`](PdfExport#pdffontdescriptor)[] | Gets or sets the list of available font descriptors. |
| `info?` | [`PdfSettingsInfo`](PdfExport#pdfsettingsinfo) | Gets or sets the document metadata. |
| `pdfVersion?` | [`PdfVersion`](PdfExport#pdfversion) | Gets or sets the PDF version. |
| `security?` | [`DocumentSecurity`](PdfExport#documentsecurity) | Gets or sets the document security settings. |

___

### <a id="pdfsettingsinfo" name="pdfsettingsinfo"></a> PdfSettingsInfo

Ƭ **PdfSettingsInfo**: `Object`

Represents PDF document metadata.

**`example`**
```ts
const info: PdfSettingsInfo = {
	title: 'Invoice',
	author: 'Contoso',
};
```

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `author?` | `string` | Gets or sets the document author. |
| `keywords?` | `string` | Gets or sets the document keywords. |
| `subject?` | `string` | Gets or sets the document subject. |
| `title?` | `string` | Gets or sets the document title. |

___

### <a id="pdfversion" name="pdfversion"></a> PdfVersion

Ƭ **PdfVersion**: ``"1.3"`` \| ``"1.4"`` \| ``"1.5"`` \| ``"1.6"`` \| ``"1.7"`` \| ``"1.7ext3"`` \| ``"PDF/A-2b"`` \| ``"PDF/A-3b"``

Represents the PDF specification version to use for export.

**`remarks`**
Accepted values:
- `'1.3'`
- `'1.4'`
- `'1.5'`
- `'1.6'`
- `'1.7'`
- `'1.7ext3'`
- `'PDF/A-2b'`
- `'PDF/A-3b'`

**`example`**
```ts
const version: PdfVersion = '1.7';
```

___

### <a id="permissions" name="permissions"></a> Permissions

Ƭ **Permissions**: `Object`

Represents PDF permissions.

**`example`**
```ts
const permissions: Permissions = {
	printing: 'highResolution',
	copying: true,
};
```

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `annotating?` | `boolean` | Gets or sets whether annotations are allowed. |
| `contentAccessibility?` | `boolean` | Gets or sets whether content accessibility is enabled. |
| `copying?` | `boolean` | Gets or sets whether copying is allowed. |
| `documentAssembly?` | `boolean` | Gets or sets whether document assembly is allowed. |
| `modifying?` | `boolean` | Gets or sets whether document modification is allowed. |
| `printing?` | ``"lowResolution"`` \| ``"highResolution"`` \| ``"none"`` | Gets or sets the printing permission.  **`remarks`** Accepted values: - `'lowResolution'` - `'highResolution'` - `'none'` |

## Functions

### <a id="exportdocument" name="exportdocument"></a> exportDocument

▸ **exportDocument**(`source`, `settings?`, `onProgress?`, `checkCancel?`): `Promise`<[`PdfExportResult`](PdfExport#pdfexportresult)\>

Exports a PageDocument or VDomRenderer to PDF.

**`example`**
```ts
const result = await exportDocument(report, { pdfVersion: '1.7' });
result.download('report.pdf');
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `source` | [`PageDocument`](../classes/Core.PageDocument) \| `VDomRenderer` | The source document or renderer to export. |
| `settings?` | [`PdfSettings`](PdfExport#pdfsettings) | The PDF export settings. |
| `onProgress?` | [`OnProgressCallback`](PdfExport#onprogresscallback) | The callback invoked after each page is rendered. |
| `checkCancel?` | [`CheckCancelCallback`](PdfExport#checkcancelcallback) | The callback invoked before rendering each page. Return `true` to cancel. |

#### Returns

`Promise`<[`PdfExportResult`](PdfExport#pdfexportresult)\>

A promise that resolves to the export result.
