Use Adorners

Loading...
Sorry, we can't retrieve the data from server. Please comeback later.

SurveyPDF adorners

You may use onRenderQuestion event to render custom elements in PDF document using internal SurveyPDF helper methods and objects

The event is fired for every rendered question. Event accepts two parameters: instance of SurveyPDF and instance of AdornersOptions object


let surveyPDF = new SurveyPDF.SurveyPDF(json);
surveyPDF.onRenderQuestion.add(function (survey, options) {
    if (options.question.name === "question_to_remove_from_pdf") {
        options.bricks = [];
    });

Bricks

AdornersOptions object contains bricks property with array of SurveyPDF internal objects which represents PDF document elements (texts, boxes, images, etc.). You may modify this array to perform custom rendering. If you leave this array without any changes then PDF will be rendered as by default

Question

AdornersOptions's question property is SurveyJS question which is rendered now

Controller

AdornersOptions has controller property which is instance of DocController object. It is required parameter to many SurveyPDF internal methods

let surveyPDF = new SurveyPDF.SurveyPDF(json);
surveyPDF.onRenderQuestion.add(function (survey, options) {
    if (options.question.name !== "filter questions like this") return;
    //SurveyPDF bricks may be composite and contain many inside one
    //call unfold() method to get plain array with all bricks inside one
    var plainBricks = options.bricks[0].unfold();
    var lastBrick = plainBricks[plainBricks.length - 1];
    //SurveyPDF has SurveyHelper object with set of useful methods
    //e.g. createPoint(rect: IRect, isLeft: boolean = true, isTop: boolean = false): IPoint
    var point = SurveyPDF.SurveyHelper.createPoint(lastBrick);
    return new Promise(function (resolve) {
        SurveyPDF.SurveyHelper.createDescFlat(point, options.question,
            options.controller, 'Some description').then(function (descBrick) {
            options.bricks.push(descBrick);
            resolve();
        });
    });
});

Point

AdornersOptions has point property (with xLeft, yTop properties) which represent point in PDF page after which you can render custom bricks below it. It is not recommended to draw above this point because you can overlap new bricks with previous

Repository

AdornersOptions also has repository property which is instance of FlatRepository object. FlatRepository has create method which instantiate FlatQuestion and it subclasses, which can be used to generate bricks with default SurveyPDF render. You may modify this bricks to achieve desired custom view

let surveyPDF = new SurveyPDF.SurveyPDF(json);
surveyPDF.onRenderQuestion.add(function (survey, options) {
    if (options.question.name !== "some_checkbox_question") return;
    //create radiogroup flatQuestion to render checkbox as radigroup
    var flatRadiogroup = options.repository.create(survey,
        options.question, options.controller, "radiogroup");
    return new Promise(function (resolve) {
        flatRadiogroup.generateFlats(options.point).then(function(radioBricks) {
            options.bricks = radioBricks;
            resolve();
        });
    });
});
Settings

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’ privacy policy and cookie policy.

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.