Issue T9009
Visible to All Users

Survey-Pdf not supporting new added component

created 3 years ago

Hi I tried to create my own custom rating "NPS (0-10)" using "rating" question type. It works on survey creator and viewer, but the when I try to export survey as pdf, this new component is not detected and I get blank pdf file. Below the code to that I used to add new component.

Code
Survey.ComponentCollection .Instance .add({ name: "nps", title: "nps", questionJSON: { type: "rating", rateValues: [ {text: "1", value: "1"}, {text: "2", value: "2"}, {text: "3", value: "3"}, {text: "4", value: "4"}, {text: "5", value: "5"}, {text: "6", value: "6"}, {text: "7", value: "7"}, {text: "8", value: "8"}, {text: "9", value: "9"}, {text: "10", value: "10"} ] }, onInit() { Survey .Serializer .addClass("rateValues", [ {name: "value:number"}, {name: "text"} ], function () { return new Survey.ItemValue(null, null, "rateValues"); }, "itemvalue"); Survey .Serializer .addProperty("nps", { name: "rateValues:rateValues[]", category: "rateValues" }); } });

To give exact example, my nps question (new component) doesn't list on console when I write this code while generating pdf.

Code
var surveyPDF = new SurveyPDF.SurveyPDF(this.json, options); surveyPDF.data = surveyModel.data; surveyPDF.getAllQuestions().forEach((q: any) => {     console.log(q.name);     });

Answers approved by surveyjs Support

created 3 years ago

Hello,
Do you run this code for SurveyJS Library Instance on export to pdf page?
It is likely that SurveyPDF model doesn't see this type.

Thank you,
Andrew
SurveyJS Team

    Comments (3)

      Thanks Andrew for reply.

      I tried to register the new component while initializing SurveyPDF class as well.

      SurveyPDF.FlatRepository.getInstance().register('nps', SurveyPDF.FlatRating);

      This however registered the type. But SurveyPDF.getAllQuestions() method doesn't return the new component question.

        Hello,
        Here is your example. SurveyJS Pdf gives error because "visibleRateValues" is undefined.
        We need to investigate the issue.
        We will be back.

        Thank you,
        Andrew
        SurveyJS Team

          I have fixed the issue in v1.9.20 that we will likely release tomorrow. Here is the related issue on GitHub.

          Thank you,
          Andrew
          SurveyJS Team