@progress/kendo-react-pdf
Version:
React PDF Processing enables you to export single- and multi-page content in PDF. KendoReact PDF Processing package
520 lines (504 loc) • 18.6 kB
TypeScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { default as default_2 } from 'prop-types';
import { DrawOptions } from '@progress/kendo-drawing';
import { Group } from '@progress/kendo-drawing';
import { JSX as JSX_2 } from 'react/jsx-runtime';
import { PageMargin } from '@progress/kendo-drawing/pdf';
import { PaperSize } from '@progress/kendo-drawing/pdf';
import { PDFOptions } from '@progress/kendo-drawing/pdf';
import * as React_2 from 'react';
import { SaveOptions } from '@progress/kendo-file-saver';
/**
* @hidden
* Returns the margin options by reading the props of he component and the `PDFMargin` child.
* The props of the `PDFMargin` child are with greater priority.
*/
export declare function getPageMargin(props: any): any;
/**
* A React component which facilitates the PDF export of the Grid.
*/
export declare class GridPDFExport extends React_2.Component<GridPDFExportProps, GridPDFExportState> {
/**
* @hidden
*/
static propTypes: {
author: default_2.Requireable<string>;
avoidLinks: default_2.Requireable<NonNullable<string | boolean | null | undefined>>;
forcePageBreak: default_2.Requireable<string>;
keepTogether: default_2.Requireable<string>;
creator: default_2.Requireable<string>;
date: default_2.Requireable<Date>;
imageResolution: default_2.Requireable<number>;
fileName: default_2.Requireable<string>;
forceProxy: default_2.Requireable<boolean>;
keywords: default_2.Requireable<string>;
landscape: default_2.Requireable<boolean>;
margin: default_2.Requireable<NonNullable<string | number | default_2.InferProps<{
left: default_2.Requireable<NonNullable<string | number | null | undefined>>;
top: default_2.Requireable<NonNullable<string | number | null | undefined>>;
right: default_2.Requireable<NonNullable<string | number | null | undefined>>;
bottom: default_2.Requireable<NonNullable<string | number | null | undefined>>;
}> | null | undefined>>;
pageTemplate: default_2.Requireable<any>;
paperSize: default_2.Requireable<any>;
repeatHeaders: default_2.Requireable<boolean>;
scale: default_2.Requireable<number>;
proxyData: default_2.Requireable<any>;
proxyURL: default_2.Requireable<string>;
proxyTarget: default_2.Requireable<string>;
producer: default_2.Requireable<string>;
subject: default_2.Requireable<string>;
title: default_2.Requireable<string>;
};
/**
* @hidden
*/
saveGridPDF: any;
/**
* @hidden
*/
grid: any;
/**
* @hidden
*/
columns: any;
/**
* @hidden
*/
data?: any[];
/**
* @hidden
*/
callback?: any;
/**
* @hidden
*/
gridInnerWrapperRef: React_2.RefObject<HTMLDivElement>;
/**
* @hidden
*/
readonly state: {
show: boolean;
};
private readonly showLicenseWatermark;
constructor(props: any);
/**
* @hidden
*/
componentDidUpdate(_prevProps: any, prevState: any): void;
/**
* @hidden
*/
render(): JSX_2.Element;
/**
* Saves the content of the Grid as a PDF file.
*
* @param data - The data can be different from the currently displayed data in the Grid. Can be used to export all Grid pages.
* @param callback - The callback that will be executed after the PDF is saved.
*/
save(data?: any[], callback?: () => void): void;
protected getSavePDF(): typeof savePDF;
private getGrid;
private getCustomColumns;
private prepareRawGridForExport;
private getGridNotColumnChildren;
}
/**
* The props of the GridPDFExport component
* ([more information and examples in the documentation on PDF export]({% slug overview_pdfexport_grid %})).
*/
export declare interface GridPDFExportProps extends PDFExportProps {
}
/**
* @hidden
*/
declare interface GridPDFExportState {
show: boolean;
}
/**
* @hidden
*/
export declare class KendoDrawingAdapter {
private drawDOM;
private exportPDF;
private saveAs;
private domElement;
private options;
constructor(drawDOM: (element: HTMLElement, options: DrawOptions) => Promise<Group>, exportPDF: (group: Group, options: PDFOptions) => Promise<string>, saveAs: (dataUri: string, fileName: string, options: SaveOptions) => void, domElement: HTMLElement, options?: PDFExportProps);
savePDF(callback?: () => void): void;
private getDrawOptions;
private getPDFOptions;
private getSaveOptions;
private convertPageTemplateToHtml;
}
/**
* Represents the props of a page template component that can be added to the PDFExport component.
*/
export declare interface PageTemplateProps {
/**
* The number of the current page.
*/
pageNum: number;
/**
* The total number of pages.
*/
totalPages: number;
}
/**
* Represents the KendoReact PDFExport component.
*/
export declare class PDFExport extends React_2.Component<PDFExportProps, {}> {
/**
* @hidden
*/
static propTypes: {
author: default_2.Requireable<string>;
avoidLinks: default_2.Requireable<NonNullable<string | boolean | null | undefined>>;
forcePageBreak: default_2.Requireable<string>;
keepTogether: default_2.Requireable<string>;
creator: default_2.Requireable<string>;
date: default_2.Requireable<Date>;
imageResolution: default_2.Requireable<number>;
fileName: default_2.Requireable<string>;
forceProxy: default_2.Requireable<boolean>;
keywords: default_2.Requireable<string>;
landscape: default_2.Requireable<boolean>;
margin: default_2.Requireable<NonNullable<string | number | default_2.InferProps<{
left: default_2.Requireable<NonNullable<string | number | null | undefined>>;
top: default_2.Requireable<NonNullable<string | number | null | undefined>>;
right: default_2.Requireable<NonNullable<string | number | null | undefined>>;
bottom: default_2.Requireable<NonNullable<string | number | null | undefined>>;
}> | null | undefined>>;
pageTemplate: default_2.Requireable<any>;
paperSize: default_2.Requireable<any>;
repeatHeaders: default_2.Requireable<boolean>;
scale: default_2.Requireable<number>;
proxyData: default_2.Requireable<any>;
proxyURL: default_2.Requireable<string>;
proxyTarget: default_2.Requireable<string>;
producer: default_2.Requireable<string>;
subject: default_2.Requireable<string>;
title: default_2.Requireable<string>;
};
private rootElForPDF;
private readonly showLicenseWatermark;
constructor(props: PDFExportProps);
/**
* @hidden
*/
render(): JSX_2.Element;
/**
* Saves the content as a PDF file.
*
* @param callback - The callback to be executed after the PDF is saved.
*/
save(callback?: () => void): void;
private getOptions;
}
/**
* Represents the props of the KendoReact PDFExport component.
*/
export declare interface PDFExportProps {
/**
* @hidden
*/
children?: React.ReactNode;
/**
* The author (metadata) of the PDF document.
*/
author?: string;
/**
* A flag that indicates whether to produce actual hyperlinks in the exported PDF file. It is also possible to set a CSS selector. All matching links will be ignored.
*/
avoidLinks?: boolean | string;
/**
* An optional CSS selector that specifies the elements which cause the page breaks.
*/
forcePageBreak?: string;
/**
* An optional CSS selector that specifies the elements which should not be split across the pages.
*/
keepTogether?: string;
/**
* The creator of the PDF document. Defaults to `KendoReact PDF Generator`.
*/
creator?: string;
/**
* The date when the PDF document is created. Defaults to `new Date()`.
*/
date?: Date;
/**
* The forced resolution of the images in the exported PDF document. By default, the images are exported at their full resolution.
*/
imageResolution?: number;
/**
* Specifies the name of the exported PDF file. Defaults to `export.pdf`.
*/
fileName?: string;
/**
* If set to `true`, the content is forwarded to `proxyURL` even if the browser supports local saving of files.
*/
forceProxy?: boolean;
/**
* The keywords (metadata) of the PDF document.
*/
keywords?: string;
/**
* A flag that indicates if the page will be in a landscape orientation. By default, the page is in a portrait orientation. Defaults to `false`.
*/
landscape?: boolean;
/**
* Specifies the margins of the page.
*
* The supported units are:
* * `"mm"`
* * `"cm"`
* * `"in"`
* * `"pt"` (default).
*
* > Numbers are considered to be points (`"pt"`).
*/
margin?: string | number | PageMargin;
/**
* A React functional or class component which is used as a template that is inserted into each page of the PDF document. The number of the current page (`pageNum`) and the total number of pages (`totalPages`) are passed to the component as properties.
*/
pageTemplate?: any;
/**
* Specifies the paper size of the PDF document. Defaults to `"auto"` which means that the paper size is determined by the content. The size of the content in pixels matches the size of the output in points (1 pixel = 1/72 inch).
*
* If set, the content will be split across multiple pages. This enables the `repeatHeaders` and `scale` options, and allows you to specify a template.
*
* The supported values are:
* * A predefined size. The supported paper sizes are: `A0-A10`, `B0-B10`, `C0-C10`, `Executive`, `Folio`, `Legal`, `Letter`, `Tabloid`.
* * An array of two numbers which specify the width and height in points (1pt = 1/72in).
* * An array of two strings which specify the width and height in units. The supported units are `"mm"`, `"cm"`, `"in"`, and `"pt"`.
*/
paperSize?: PaperSize;
/**
* Specifies if the `<thead>` elements of the tables will be repeated on each page.
*/
repeatHeaders?: boolean;
/**
* A scale factor. The text size on the screen might be too big for printing. To scale down the output in PDF, use this option. Defaults to `1`.
*/
scale?: number;
/**
* A key/value dictionary of form values which will be sent to the proxy. Can be used to submit Anti-Forgery tokens and other metadata.
*/
proxyData?: {
[key: string]: string;
};
/**
* The URL of the server-side proxy which streams the file to the end user. You need to use a proxy if the browser is not capable of saving files locally—for example, Internet Explorer 9 and Safari. It is your responsibility to implement the server-side proxy.
*
* In the request body, the proxy receives a `POST` request with the following parameters:
* - `"contentType"`—The MIME type of the file.
* - `"base64"`—The base-64 encoded file content.
* - `"fileName"`—The file name, as requested by the caller.
*
* The proxy returns the decoded file with the `"Content-Disposition"` header set to `attachment;
* filename="<fileName.pdf>"`.
*/
proxyURL?: string;
/**
* A name or keyword which indicates where to display the document that is returned from the proxy. To display the document in a new window or iframe, the proxy has to have the `"Content-Disposition"` header set to `inline; filename="<fileName.pdf>"`. Defaults to `_self`.
*/
proxyTarget?: string;
/**
* The producer (metadata) of the PDF document.
*/
producer?: string;
/**
* The subject (metadata) of the PDF document.
*/
subject?: string;
/**
* The title (metadata) of the PDF document.
*/
title?: string;
}
/**
* @hidden
*/
export declare class PDFMargin extends React_2.Component<PDFMarginProps, {}> {
static propTypes: {
left: default_2.Requireable<NonNullable<string | number | null | undefined>>;
top: default_2.Requireable<NonNullable<string | number | null | undefined>>;
right: default_2.Requireable<NonNullable<string | number | null | undefined>>;
bottom: default_2.Requireable<NonNullable<string | number | null | undefined>>;
};
render(): null;
}
/**
* Represents the props of the KendoReact PDFMargin component.
*/
export declare interface PDFMarginProps {
/**
* The bottom margin.
*
* The supported units are:
* * `"mm"`
* * `"cm"`
* * `"in"`
* * `"pt"` (default).
*
* > Numbers are considered to be points (`"pt"`).
*/
left?: number | string;
/**
* The top margin.
*
* The supported units are:
* * `"mm"`
* * `"cm"`
* * `"in"`
* * `"pt"` (default).
*
* > Numbers are considered to be points (`"pt"`).
*/
top?: number | string;
/**
* The right margin.
*
* The supported units are:
* * `"mm"`
* * `"cm"`
* * `"in"`
* * `"pt"` (default).
*
* > Numbers are considered to be points (`"pt"`).
*/
right?: number | string;
/**
* The bottom margin.
*
* The supported units are:
* * `"mm"`
* * `"cm"`
* * `"in"`
* * `"pt"` (default).
*
* > Numbers are considered to be points (`"pt"`).
*/
bottom?: number | string;
}
/**
* Saves the content of a DOM element to a PDF file.
*
* @param domElement - The root DOM element to save to a PDF file.
* @param options - The export options.
* @param callback - The callback to be executed after the PDF is saved.
*/
export declare function savePDF(domElement: HTMLElement, options?: PDFExportProps, callback?: () => void): void;
/**
* A React component which facilitates the PDF export of the TreeList.
*/
export declare class TreeListPDFExport extends React_2.Component<TreeListPDFExportProps, TreeListPDFExportState> {
/**
* @hidden
*/
static propTypes: {
author: default_2.Requireable<string>;
avoidLinks: default_2.Requireable<NonNullable<string | boolean | null | undefined>>;
forcePageBreak: default_2.Requireable<string>;
keepTogether: default_2.Requireable<string>;
creator: default_2.Requireable<string>;
date: default_2.Requireable<Date>;
imageResolution: default_2.Requireable<number>;
fileName: default_2.Requireable<string>;
forceProxy: default_2.Requireable<boolean>;
keywords: default_2.Requireable<string>;
landscape: default_2.Requireable<boolean>;
margin: default_2.Requireable<NonNullable<string | number | default_2.InferProps<{
left: default_2.Requireable<NonNullable<string | number | null | undefined>>;
top: default_2.Requireable<NonNullable<string | number | null | undefined>>;
right: default_2.Requireable<NonNullable<string | number | null | undefined>>;
bottom: default_2.Requireable<NonNullable<string | number | null | undefined>>;
}> | null | undefined>>;
pageTemplate: default_2.Requireable<any>;
paperSize: default_2.Requireable<any>;
repeatHeaders: default_2.Requireable<boolean>;
scale: default_2.Requireable<number>;
proxyData: default_2.Requireable<any>;
proxyURL: default_2.Requireable<string>;
proxyTarget: default_2.Requireable<string>;
producer: default_2.Requireable<string>;
subject: default_2.Requireable<string>;
title: default_2.Requireable<string>;
allPages: default_2.Requireable<boolean>;
};
/**
* @hidden
*/
saveTreeListPDF: any;
/**
* @hidden
*/
treeList: any;
/**
* @hidden
*/
columns: any;
/**
* @hidden
*/
data?: any[];
/**
* @hidden
*/
callback?: any;
/**
* @hidden
*/
treeListInnerWrapperRef: React_2.RefObject<HTMLDivElement>;
/**
* @hidden
*/
readonly state: {
show: boolean;
};
private readonly showLicenseWatermark;
constructor(props: any);
/**
* @hidden
*/
componentDidUpdate(_prevProps: any, prevState: any): void;
/**
* @hidden
*/
render(): JSX_2.Element;
/**
* Saves the content of the TreeList as a PDF file.
*
* @param data - The data that will be exported to the PDF. The data can be different from the currently displayed data in the TreeList.
* @param columns - The columns that will be exported to the PDF. The columns collection can be different from the currently displayed in the TreeList.
* @param callback - The callback that will be executed after the PDF is saved.
*/
save(data?: any[], columns?: any[], callback?: () => void): void;
protected getSavePDF(): typeof savePDF;
private getTreeList;
private prepareRawTreeListForExport;
}
/**
* The props of the TreeListPDFExport component
* ([more information and examples in the documentation on PDF export]({% slug overview_pdfexport_treelist %})).
*/
export declare interface TreeListPDFExportProps extends PDFExportProps {
/**
* If set to true it will export all pages of the TreeList data. By default allPages is set to `false`.
*/
allPages?: boolean;
}
/**
* @hidden
*/
declare interface TreeListPDFExportState {
show: boolean;
}
export { }