UNPKG

survey-pdf

Version:

A UI component that uses SurveyJS form JSON schemas to render forms as PDF documents. It populates PDF fields with data collected using SurveyJS Form Library and lets you export your SurveyJS forms as editable or pre-filled PDFs.

87 lines (86 loc) 3 kB
import { IRect, ISize, DocController } from '../doc_controller'; import { IQuestion } from 'survey-core'; export type TranslateXFunction = (xLeft: number, xRight: number) => { xLeft: number; xRight: number; }; export interface IPdfBrick extends IRect, ISize { render(): Promise<void>; unfold(): IPdfBrick[]; translateX(func: TranslateXFunction): void; isPageBreak: boolean; } /** * An object that describes a PDF brick&mdash;a simple element with specified content, size, and location. Bricks are fundamental elements used to construct a PDF document. * * You can access `PdfBrick` objects within functions that handle `SurveyPDF`'s [`onRenderQuestion`](https://surveyjs.io/pdf-generator/documentation/api-reference/surveypdf#onRenderQuestion), [`onRenderPanel`](https://surveyjs.io/pdf-generator/documentation/api-reference/surveypdf#onRenderPanel), and [`onRenderPage`](https://surveyjs.io/pdf-generator/documentation/api-reference/surveypdf#onRenderPage) events. * * [View Demo](https://surveyjs.io/pdf-generator/examples/add-markup-to-customize-pdf-forms/ (linkStyle)) */ export declare class PdfBrick implements IPdfBrick { protected question: IQuestion; protected controller: DocController; protected _xLeft: number; protected _xRight: number; protected _yTop: number; protected _yBot: number; /** * An X-coordinate for the left brick edge. */ get xLeft(): number; set xLeft(val: number); /** * An X-coordinate for the right brick edge. */ get xRight(): number; set xRight(val: number); /** * A Y-coordinate for the top brick edge. */ get yTop(): number; set yTop(val: number); /** * A Y-coordinate for the bottom brick edge. */ get yBot(): number; set yBot(val: number); /** * Font size in points. * * Default value: 14 (inherited from the parent PDF document) */ fontSize: number; /** * The color of text within the brick. * * Default value: `"#404040"` */ textColor: string; formBorderColor: string; isPageBreak: boolean; constructor(question: IQuestion, controller: DocController, rect: IRect); translateX(func: TranslateXFunction): void; /** * The brick's width in pixels. */ get width(): number; /** * The brick's height in pixels. */ get height(): number; protected getShouldRenderReadOnly(): boolean; afterRenderCallback: () => void; render(): Promise<void>; renderInteractive(): Promise<void>; renderReadOnly(): Promise<void>; /** * Allows you to get a flat array of nested PDF bricks. * @returns A flat array of nested PDF bricks. */ unfold(): IPdfBrick[]; protected getCorrectedText(val: string): string; protected setXLeft(val: number): void; protected setXRight(val: number): void; protected setYTop(val: number): void; protected setYBottom(val: number): void; }