SurveyPDF

The SurveyPDF object enables you to export your surveys and forms to PDF documents.

View Demo

applyStyle method

Applies a visual style to UI elements in an exported PDF document.

This method accepts either an IDocStyle object that overrides properties in the default visual style, or a callback function that returns such an object. When a callback is used, it receives helper functions—getSizeVariable(name) and getColorVariable(name)—which allow you to derive dimensions and colors from the currently applied UI theme.

Customize Styling and Layout in PDF

Type:
(value: IDocStyle | ((options: { getColorVariable: (name: string) => string; getSizeVariable: (name: string) => number; }) => IDocStyle)) => void
Parameters:
value, type: IDocStyle | ((options: { getColorVariable: (name: string) => string; getSizeVariable: (name: string) => number; }) => IDocStyle) ,

An IDocStyle object, or a callback function that returns an IDocStyle object.

Implemented in:
SurveyPDF

An event that allows you to customize the visual style applied to a choice item in an exported PDF document.

Parameters:

  • sender: SurveyPDF
    A SurveyPDF instance that raised the event.
  • options.question: Question
    A question to which the item belongs.
  • options.item: ItemValue
    A choice item whose style is being customized.
  • options.getColorVariable: (name: string) => string
    A helper function that returns the value of a color variable by name.
  • options.getSizeVariable: (name: string) => number
    A helper function that returns the value of a size variable by name.
  • options.style.choiceText: ITextStyle
    An object that defines the visual style applied to the item's text.
  • options.style.input: ISelectionInputStyle
    An object that defines the visual style applied to the item's input control.

Modify the properties of options.style.choiceText and options.style.input to control how the item is rendered in the exported PDF document.

Customize Individual Element Styles in PDF

Type:
EventBase<SurveyPDF, { question: Question; item: ItemValue; style: { choiceText: ITextStyle; input: ISelectionInputStyle; }; getColorVariable: (name: string) => string; getSizeVariable: (name: string) => number; }>
Implemented in:
SurveyPDF

An event that allows you to customize the visual style applied to a page in an exported PDF document.

Parameters:

  • sender: SurveyPDF
    A SurveyPDF instance that raised the event.
  • options.page: PageModel
    A page whose style is being customized.
  • options.getColorVariable: (name: string) => string
    A helper function that returns the value of a color variable by name.
  • options.getSizeVariable: (name: string) => number
    A helper function that returns the value of a size variable by name.
  • options.style: IPageStyle
    An object that defines the page's visual style. Modify its properties to control how the page is rendered in the exported PDF document.

Customize Individual Element Styles in PDF

Type:
EventBase<SurveyPDF, { page: PanelModel; style: IPageStyle; getColorVariable: (name: string) => string; getSizeVariable: (name: string) => number; }>
Implemented in:
SurveyPDF

An event that allows you to customize the visual style applied to a panel in an exported PDF document.

Parameters:

  • sender: SurveyPDF
    A SurveyPDF instance that raised the event.
  • options.panel: PanelModel
    A panel whose style is being customized.
  • options.getColorVariable: (name: string) => string
    A helper function that returns the value of a color variable by name.
  • options.getSizeVariable: (name: string) => number
    A helper function that returns the value of a size variable by name.
  • options.style: IPanelStyle
    An object that defines the panel's visual style. Modify its properties to control how the panel is rendered in the exported PDF document.

Customize Individual Element Styles in PDF

Type:
EventBase<SurveyPDF, { panel: PanelModel; style: IPanelStyle; getColorVariable: (name: string) => string; getSizeVariable: (name: string) => number; }>
Implemented in:
SurveyPDF

An event that allows you to customize the visual style applied to a question in an exported PDF document.

Parameters:

  • sender: SurveyPDF
    A SurveyPDF instance that raised the event.
  • options.question: Question
    A survey question whose style is being customized.
  • options.getColorVariable: (name: string) => string
    A helper function that returns the value of a color variable by name.
  • options.getSizeVariable: (name: string) => number
    A helper function that returns the value of a size variable by name.
  • options.style: IQuestionStyle
    An object that defines the question's visual style. Modify its properties to control how the question is rendered in the exported PDF document.

Customize Individual Element Styles in PDF

Type:
EventBase<SurveyPDF, { question: Question; style: IQuestionStyle; getColorVariable: (name: string) => string; getSizeVariable: (name: string) => number; }>
Implemented in:
SurveyPDF

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
    An object that you can use to draw text and images in the page footer. View Demo
Type:
EventAsync<SurveyPDF, DrawCanvas>
Implemented in:
SurveyPDF

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
    An object that you can use to draw text and images in the page header. View Demo
Type:
EventAsync<SurveyPDF, DrawCanvas>
Implemented in:
SurveyPDF
onRenderPage event

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
    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[]
    An array of bricks used to render the element.
  • options.controller: 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.
Type:
EventAsync<SurveyPDF, AdornersPageOptions>
Implemented in:
SurveyPDF

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
    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[]
    An array of bricks used to render the element.
  • options.controller: 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.
Type:
EventAsync<SurveyPDF, AdornersPanelOptions>
Implemented in:
SurveyPDF

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
    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[]
    An array of bricks used to render the element.
  • options.controller: 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.
Type:
EventAsync<SurveyPDF, AdornersOptions>
Implemented in:
SurveyPDF
raw method

An asynchronous method that allows you to get PDF content in different formats.

View Demo

Type:
{ (): any; (type: "arraybuffer"): any; (type: "blob"): any; (type: "bloburl"): any; (type: "dataurlstring"): any; }
Parameters:
type, type: string
Implemented in:
SurveyPDF
save method

An asynchronous method that starts to download the generated PDF file in the web browser.

View Demo

Type:
(fileName?: string) => any
Parameters:
fileName, type: string ,

(Optional) A file name with the ".pdf" extension. Default value: "survey_result.pdf".

Implemented in:
SurveyPDF
style property

An object that defines the visual style applied to UI elements in an exported PDF document.

To apply a new visual style to the PDF document, call the applyStyle method.

Customize Styling and Layout in PDF

Type:
IDocStyle readonly
Implemented in:
SurveyPDF

Send feedback to the SurveyJS team

Need help? Visit our support page

Your cookie settings

We use cookies to make your browsing experience more convenient and personal. Some cookies are essential, while others help us analyse traffic. Your personal data and cookies may be used for ad personalization. By clicking “Accept All”, you consent to the use of all cookies as described in our Terms of Use and Privacy Statement. You can manage your preferences in “Cookie settings.”

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.