UNPKG

survey-pdf

Version:

survey.pdf.js is a SurveyJS PDF Library. It is a easy way to export SurveyJS surveys to PDF. It uses JSON for survey metadata.

154 lines (153 loc) 8.2 kB
import { SurveyModel, EventBase } from 'survey-core'; import { IDocOptions, DocController } from './doc_controller'; import { EventAsync } from './event_handler/event_handler'; import { DrawCanvas } from './event_handler/draw_canvas'; import { AdornersOptions, AdornersPanelOptions, AdornersPageOptions } from './event_handler/adorners'; /** * The `SurveyPDF` object enables you to export your surveys and forms to PDF documents. * * [View Demo](https://surveyjs.io/pdf-generator/examples/ (linkStyle)) */ export declare class SurveyPDF extends SurveyModel { private static currentlySaving; private static saveQueue; options: IDocOptions; constructor(jsonObject: any, options?: IDocOptions); get haveCommercialLicense(): boolean; set haveCommercialLicense(val: boolean); /** * An event that is raised when SurveyJS PDF Generator renders a page header. Handle this event to customize the header. * * Parameters: * * - `sender`: `SurveyPDF`\ * A SurveyPDF instance that raised the event. * * - `canvas`: [`DrawCanvas`](https://surveyjs.io/pdf-generator/documentation/api-reference/drawcanvas)\ * An object that you can use to draw text and images in the page header. * * [View Demo](https://surveyjs.io/pdf-generator/examples/customize-header-and-footer-of-pdf-form/ (linkStyle)) */ onRenderHeader: EventAsync<SurveyPDF, DrawCanvas>; /** * An event that is raised when SurveyJS PDF Generator renders a page footer. Handle this event to customize the footer. * * Parameters: * * - `sender`: `SurveyPDF`\ * A SurveyPDF instance that raised the event. * * - `canvas`: [`DrawCanvas`](https://surveyjs.io/pdf-generator/documentation/api-reference/drawcanvas)\ * An object that you can use to draw text and images in the page footer. * * [View Demo](https://surveyjs.io/pdf-generator/examples/customize-header-and-footer-of-pdf-form/ (linkStyle)) */ onRenderFooter: EventAsync<SurveyPDF, DrawCanvas>; /** * An event that is raised when SurveyJS PDF Generator renders a survey question. Handle this event to customize question rendering. * * Parameters: * * - `sender`: `SurveyPDF`\ * A SurveyPDF instance that raised the event. * * - `options.question`: [`Question`](https://surveyjs.io/form-library/documentation/api-reference/question)\ * A survey question that is being rendered. * * - `options.point`: `IPoint`\ * An object with coordinates of the top-left corner of the element being rendered. This object contains the following properties: `{ xLeft: number, yTop: number }`. * * - `options.bricks`: [`PdfBrick[]`](https://surveyjs.io/pdf-generator/documentation/api-reference/pdfbrick)\ * An array of [bricks](https://surveyjs.io/pdf-generator/documentation/customize-survey-question-rendering-in-pdf-form#custom-rendering) used to render the element. * * - `options.controller`: [`DocController`](https://surveyjs.io/pdf-generator/documentation/api-reference/doccontroller)\ * An object that provides access to main PDF document properties (font, margins, page width and height) and allows you to modify them. * * - `options.repository`: `FlatRepository`\ * A repository with classes that render elements to PDF. Use its `create` method if you need to create a new instance of a rendering class. * * [View Demo](https://surveyjs.io/pdf-generator/examples/how-to-use-adorners-in-pdf-forms/ (linkStyle)) */ onRenderQuestion: EventAsync<SurveyPDF, AdornersOptions>; /** * An event that is raised when SurveyJS PDF Generator renders a panel. Handle this event to customize panel rendering. * * Parameters: * * - `sender`: `SurveyPDF`\ * A SurveyPDF instance that raised the event. * * - `options.panel`: [`PanelModel`](https://surveyjs.io/form-library/documentation/api-reference/panel-model)\ * A panel that is being rendered. * * - `options.point`: `IPoint`\ * An object with coordinates of the top-left corner of the element being rendered. This object contains the following properties: `{ xLeft: number, yTop: number }`. * * - `options.bricks`: [`PdfBrick[]`](https://surveyjs.io/pdf-generator/documentation/api-reference/pdfbrick)\ * An array of [bricks](https://surveyjs.io/pdf-generator/documentation/customize-survey-question-rendering-in-pdf-form#custom-rendering) used to render the element. * * - `options.controller`: [`DocController`](https://surveyjs.io/pdf-generator/documentation/api-reference/doccontroller)\ * An object that provides access to main PDF document properties (font, margins, page width and height) and allows you to modify them. * * - `options.repository`: `FlatRepository`\ * A repository with classes that render elements to PDF. Use its `create` method if you need to create a new instance of a rendering class. * * [View Demo](https://surveyjs.io/pdf-generator/examples/how-to-use-adorners-in-pdf-forms/ (linkStyle)) */ onRenderPanel: EventAsync<SurveyPDF, AdornersPanelOptions>; /** * An event that is raised when SurveyJS PDF Generator renders a page. Handle this event to customize page rendering. * * Parameters: * * - `sender`: `SurveyPDF`\ * A SurveyPDF instance that raised the event. * * - `options.page`: [`PageModel`](https://surveyjs.io/form-library/documentation/api-reference/page-model)\ * A page that is being rendered. * * - `options.point`: `IPoint`\ * An object with coordinates of the top-left corner of the element being rendered. This object contains the following properties: `{ xLeft: number, yTop: number }`. * * - `options.bricks`: [`PdfBrick[]`](https://surveyjs.io/pdf-generator/documentation/api-reference/pdfbrick)\ * An array of [bricks](https://surveyjs.io/pdf-generator/documentation/customize-survey-question-rendering-in-pdf-form#custom-rendering) used to render the element. * * - `options.controller`: [`DocController`](https://surveyjs.io/pdf-generator/documentation/api-reference/doccontroller)\ * An object that provides access to main PDF document properties (font, margins, page width and height) and allows you to modify them. * * - `options.repository`: `FlatRepository`\ * A repository with classes that render elements to PDF. Use its `create` method if you need to create a new instance of a rendering class. * * [View Demo](https://surveyjs.io/pdf-generator/examples/how-to-use-adorners-in-pdf-forms/ (linkStyle)) */ onRenderPage: EventAsync<SurveyPDF, AdornersPageOptions>; onDocControllerCreated: EventBase<SurveyPDF, { controller: DocController; }>; onRenderCheckItemAcroform: EventAsync<SurveyPDF, any>; onRenderRadioGroupWrapAcroform: EventAsync<SurveyPDF, any>; onRenderRadioItemAcroform: EventAsync<SurveyPDF, any>; private ensureQuestionDisplayValue; private waitForQuestionIsReady; private waitForCoreIsReady; getUpdatedCheckItemAcroformOptions(options: any): void; getUpdatedRadioGroupWrapOptions(options: any): void; getUpdatedRadioItemAcroformOptions(options: any): void; private correctBricksPosition; protected renderSurvey(controller: DocController): Promise<void>; /** * An asynchronous method that starts download of the generated PDF file in the web browser. * * @param fileName *(Optional)* A file name with the ".pdf" extension. Default value: `"survey_result.pdf"`. */ save(fileName?: string): Promise<any>; /** * An asynchronous method that allows you to get PDF content in different formats. * * [View Demo](https://surveyjs.io/pdf-generator/examples/convert-pdf-form-blob-base64-raw-pdf-javascript/ (linkStyle)) * * @param type *(Optional)* One of `"blob"`, `"bloburl"`, `"dataurlstring"`. Do not specify this parameter if you want to get raw PDF content as a string value. * */ raw(type?: string): Promise<string>; }