In my survey js instance my rating is horizontal, but when I export it to a pdf its making it vertically stacked. I am not too sure how to make it stack horizontally. Any help is appreciated
Rating horizontal rendering and pdf export
Answers approved by surveyjs Support
Hello,
As most simple way you can increase value of RATING_COLUMN_WIDTH
constant of SurveyPDF. By default it equals 5
and means five standard width units. If description of any rate value exceeds this width then render will choose vertical layout:
JavaScriptSurveyPDF.SurveyHelper.RATING_COLUMN_WIDTH = 12;
Here live sample of this approach:
Thanks, Alex
SurveyJS Team
Thanks alot for this! It worked. Is there a way to remove the min and max labels off the rectangles and more on the left and right, similar to the surveyjs version
Hello,
Unfortunately, there is no simple option to do this. But you can use approach with manipulating survey structure described here and SurveyPDF Adorners mechanism to recreate wide variety of complex markups
For example your case can be solved with following code tricks:
JavaScriptsurveyPDF.getAllQuestions().forEach((q) => {
if (q.getType() == "rating") {
var checkQtitle = Survey.Serializer.createClass('checkbox');
checkQtitle.title = q.title;
q.parent.addElement(checkQtitle, q.parent.elements.indexOf(q));
var checkQmaxrate = Survey.Serializer.createClass('checkbox');
checkQmaxrate.name = "checkQmaxrate";
checkQmaxrate.title = q.maxRateDescription;
checkQmaxrate.hideNumber = true;
checkQmaxrate.startWithNewLine = false;
q.parent.addElement(checkQmaxrate, q.parent.elements.indexOf(q) + 1);
q.titleLocation = "left";
q.title = q.minRateDescription;
q.minRateDescription = q.maxRateDescription = "";
q.hideNumber = true;
q.width = "600px";
}
});
surveyPDF.onRenderQuestion.add((sender, options) => {
if (options.question.name === "checkQmaxrate") {
options.bricks[0].xLeft -= options.controller.unitWidth * 1.5;
options.bricks[0].xRight -= options.controller.unitWidth * 1.5;
}
if (options.question.name === "rating") {
var bricks = options.bricks[0].unfold();
for (var i = 1; i < bricks.length; i++) {
bricks[i].yTop -= options.controller.unitHeight;
bricks[i].yBot -= options.controller.unitHeight;
}
}
});
Here is live sample of this:
Thanks, Alex
SurveyJS Team
Hello,
We will take a look at this case and write back to this thread immediately
Thanks, Alex
SurveyJS Team
Thank you!