I want to save my completed survey as a PDF within which all the tick boxes of chosen options are fully filled with a color (black) but not just a tiny dot.
Fully fill the tick box with color
Answers approved by surveyjs Support
Hello,
Thank you for your patience. To fill a checked matrix option with a solid color, implement the SurveyPDF.onRenderQuestion
function, obtain a target brick and use the doc.setFillColor jsPDF function to fill a cell box with a solid color. Consider the following code: View Demo.
JavaScript surveyPDF.onRenderQuestion.add((sender, options) => {
if(options.question.getType() != "matrix") return;
options.bricks.forEach((brick) => {
brick.unfold().forEach((innerBrick) => {
if(!!innerBrick.radioGroupWrap && innerBrick.context.checked){
const doc = options.controller.doc;
const itemBackground = "#9F9F9F";
const targetBrick = innerBrick;
let oldFillColor = doc.getFillColor();
doc.setFillColor(itemBackground);
const x = targetBrick.xLeft;
const y = targetBrick.yTop;
const width = targetBrick.width;
const height = targetBrick.height;
doc.rect(x, y, width, height, "F");
doc.setFillColor(oldFillColor);
}
})
})
});
Should you have further questions, please do let me know.
Hello,
A Checkbox question is exported as an editable acro-form and appears as a check item:
Would you please elaborate on the target output? Do you wish to fill a check box with a solid color and export a survey to PDF as an editable form?
When a respondent submit a filled-out form, a static read-only PDF is generated on my platform and can be downloaded (as shown in the picture below). What I want is all the boxes marking my selected options (not just that of multiple-choice questions) to be filled with a solid color. Currently, they are just put in with small dots, which is hard to make out on physical papers.
Hello,
Thank you for the clarification. I may need additional time to consider an option. Please stay tuned.
Hello,
Unfortunately, there is no built-in option to render a filled-in box instead of a radio item. We may consider an option to achieve that. Please follow this issue: https://github.com/surveyjs/survey-pdf/issues/304.
Thanks