surveyjs / survey-pdf

Supplementary component to the SurveyJS Form Library to download surveys as PDF files and generate editable PDF forms.
https://surveyjs.io/pdf-generator/examples/survey-pdf-export/
Other
61 stars 30 forks source link

Boolean rendered as Checkbox doesn't display a label in PDF #297

Open JaneSjs opened 7 months ago

JaneSjs commented 7 months ago

User Issue: T16746 - survey-pdf https://surveyjs.answerdesk.io/internal/ticket/details/T16746


View Demo

In a survey runner: image

In PDF: image image

Expected behavior: in PDF, a label appears beside a checkbox.

JaneSjs commented 7 months ago

We researched this task. Currently, a Boolean question rendered as 'checkbox' renders the labelTrue and labelFalse labels in PDF. Unfortunately, we may not change this behavior in the meantime and render the label instead because it may introduce a breaking change. While researching this task, we found another issue which highlights ambiguous settings of the 'checkbox' rendering mode. We may require to rework the 'checkbox' rendering mode in the future and eliminate those issues.

In the meantime, consider the following alternatives.

Option 1: Use the 'checkbox' rendering mode for a Boolean question and set the labelTrue and labelFalse properties to the label text. You would require to copy the label to the labelTrue and labelFalse properties. View Plunker

{
  "pages": [{
    "elements": [
      {
        "type": "boolean",
        "name": "Birthdate_Refused",
        "label": "Refused",
        "labelTrue": "Refused",
        "labelFalse": "Refused",
        "titleLocation": "hidden",
        "hideNumber": true,
        "renderAs": "checkbox",
        "valueTrue": 1,
        "valueFalse": 0
       }
    ]
  }]
}

Option 2: Use the Checkbox question instead of a Boolean question. With this option, you would configure a regular Checkbox question with a single check item. Consider the following demo: View Plunker

{
 "pages": [
  {
   "name": "page1",
   "elements": [
    {
     "type": "checkbox",
     "name": "Birthdate_Refused",
     "title": "Birthday",
     "hideNumber": true,
     "choices": [
      {
       "value": "refused",
       "text": "Refused"
      }
     ]
    }
   ]
  }
 ]
}