[]
        
(Showing Draft Content)

PdfExport

Namespace: PdfExport

Table of contents

Type aliases

Functions

Type aliases

CheckCancelCallback

Ƭ CheckCancelCallback: () => boolean

Type declaration

▸ (): boolean

Defines a callback that determines whether export should be canceled.

example

const shouldCancel: CheckCancelCallback = () => false;
Returns

boolean

true to cancel the export; otherwise, false.


DocumentSecurity

Ƭ DocumentSecurity: Object

Represents document security settings.

example

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 Gets or sets the document permissions.
userPassword? string Gets or sets the user password used to open the document.

OnProgressCallback

Ƭ OnProgressCallback: (pageNumber: number) => void

Type declaration

▸ (pageNumber): void

Defines a callback invoked after each page is rendered.

example

const onProgress: OnProgressCallback = (pageNumber) => console.log(pageNumber);
Parameters
Name Type Description
pageNumber number The one-based page number that has finished rendering.
Returns

void


PdfExportResult

Ƭ PdfExportResult: Object

Represents the result of a PDF export.

example

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');

PdfFontDescriptor

Ƭ PdfFontDescriptor: Object

Represents a PDF font descriptor.

example

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.

PdfSettings

Ƭ PdfSettings: Object

Represents PDF export settings.

example

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[] Gets or sets the list of available font descriptors.
info? PdfSettingsInfo Gets or sets the document metadata.
pdfVersion? PdfVersion Gets or sets the PDF version.
security? DocumentSecurity Gets or sets the document security settings.

PdfSettingsInfo

Ƭ PdfSettingsInfo: Object

Represents PDF document metadata.

example

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.

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

const version: PdfVersion = '1.7';

Permissions

Ƭ Permissions: Object

Represents PDF permissions.

example

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

exportDocument

exportDocument(source, settings?, onProgress?, checkCancel?): Promise<PdfExportResult>

Exports a PageDocument or VDomRenderer to PDF.

example

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

Parameters

Name Type Description
source PageDocument | VDomRenderer The source document or renderer to export.
settings? PdfSettings The PDF export settings.
onProgress? OnProgressCallback The callback invoked after each page is rendered.
checkCancel? CheckCancelCallback The callback invoked before rendering each page. Return true to cancel.

Returns

Promise<PdfExportResult>

A promise that resolves to the export result.