Documentation Docs
Documentation Docs

Export HTML to PDF

SurveyPDF can export HTML markup to PDF via SurveyJS Html questions. Nevertheless, it is a difficult task to map HTML elements to PDF document primitives. Therefore, SurveyPDF automatically chooses the more suitable from two render types - standard text or image. If the given HTML markup is simple enough, it will be rendered as selectable text in the PDF document (this is appropriate for long descriptive texts with a simple layout). Otherwise (if the HTML markup is complex), it will be rendered as an image (this is suitable for greeting texts that might have an elaborate layout).

You can set the preferred render mode directly to fit your needs more accurately. Pass the 'standard' value through the htmlRenderAs parameter to render all HTML questions as selectable texts. Or pass the 'image' value to render all HTML questions as images. The default value is 'auto'.

const options = {
    htmlRenderAs: 'image'
};
const surveyPDF = new SurveyPDF.SurveyPDF(json, options);

Also, you can override the render of a particular HTML question by setting its renderAs property to the 'standard' or 'image' value correspondingly. The default value is 'auto'.

const json = {
    elements: [
        {
            type: 'html',
            name: 'html_as_image',
            html: '<i>Cheeese!</i>',
            renderAs: 'image'
        }
    ]
};

See Also
Options in SurveyPDF Constructor: HTML question render mode

Use custom font in HTML

In case of rendering HTML as ans image, you can pass true through the useCustomFontInHtml parameter to use custom font in HTML. The default value is false.
Please, note that using a custom font in HTML can increase the time of export.
See more: Information about custom fonts in SurveyPDF

const options = {
    fontName: 'custom',
    base64Bold: 'base64 encoded font',
    htmlRenderAs: 'image',
    useCustomFontInHtml: true
};
const surveyPDF = new SurveyPDF.SurveyPDF(json, options);

See Also
Options in SurveyPDF Constructor: Ability to use custom fonts in HTML questions

Copyright © 2023 Devsoft Baltic OÜ. All rights reserved.

Why we use cookies.

This site uses cookies to make your browsing experience more convenient and personal. Cookies store useful information on your computer to help us improve the efficiency and relevance of our site for you. In some cases, they are essential to making the site work properly. By accessing this site, you consent to the use of cookies.

For more information, refer to DevSoft Baltic’ Terms of Use & Privacy Statement.

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.