survey-pdf 2.2.5 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS PDF library v2.2.5
2
+ * surveyjs - SurveyJS PDF library v2.3.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS PDF library v2.2.5
2
+ * surveyjs - SurveyJS PDF library v2.3.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS PDF library v2.2.5
2
+ * surveyjs - SurveyJS PDF library v2.3.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS PDF library v2.2.5
2
+ * surveyjs - SurveyJS PDF library v2.3.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS PDF library v2.2.5
2
+ * surveyjs - SurveyJS PDF library v2.3.0
3
3
  * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
4
  * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
5
  */
@@ -1710,19 +1710,6 @@ class SurveyHelper {
1710
1710
  return text.renderedHtml;
1711
1711
  return text.renderedText || text.renderedHtml;
1712
1712
  }
1713
- static getDropdownQuestionValue(question) {
1714
- const qDropDown = question;
1715
- if (qDropDown.isOtherSelected) {
1716
- return qDropDown.otherText;
1717
- }
1718
- else if (!!question.displayValue) {
1719
- return question.displayValue;
1720
- }
1721
- else if (qDropDown.showOptionsCaption) {
1722
- return qDropDown.optionsCaption;
1723
- }
1724
- return '';
1725
- }
1726
1713
  static getContentQuestion(question) {
1727
1714
  return !!question.contentQuestion ? question.contentQuestion : question;
1728
1715
  }
@@ -7834,6 +7821,19 @@ class FlatSelectBase extends FlatQuestion {
7834
7821
  this.controller = controller;
7835
7822
  this.question = question;
7836
7823
  }
7824
+ generateItemComment(point, item) {
7825
+ return __awaiter(this, void 0, void 0, function* () {
7826
+ const commentModel = this.question.getCommentTextAreaModel(item);
7827
+ return yield SurveyHelper.createCommentFlat(point, this.question, this.controller, {
7828
+ fieldName: commentModel.id,
7829
+ rows: SurveyHelper.OTHER_ROWS_COUNT,
7830
+ value: commentModel.getTextValue(),
7831
+ shouldRenderBorders: settings.readOnlyCommentRenderMode === 'textarea',
7832
+ isReadOnly: this.question.isReadOnly,
7833
+ isMultiline: true,
7834
+ });
7835
+ });
7836
+ }
7837
7837
  generateFlatComposite(point, item, index) {
7838
7838
  return __awaiter(this, void 0, void 0, function* () {
7839
7839
  const compositeFlat = new CompositeBrick();
@@ -7845,18 +7845,10 @@ class FlatSelectBase extends FlatQuestion {
7845
7845
  if (item.locText.renderedHtml !== null) {
7846
7846
  compositeFlat.addBrick(yield SurveyHelper.createTextFlat(textPoint, this.question, this.controller, item.locText, TextBrick));
7847
7847
  }
7848
- if (item === this.question.otherItem && (item.value === this.question.value ||
7849
- (typeof this.question.isOtherSelected !== 'undefined' && this.question.isOtherSelected))) {
7850
- const otherPoint = SurveyHelper.createPoint(compositeFlat);
7848
+ if (item.isCommentShowing) {
7849
+ const otherPoint = SurveyHelper.createPoint(compositeFlat, true, false);
7851
7850
  otherPoint.yTop += this.controller.unitHeight * SurveyHelper.GAP_BETWEEN_ROWS;
7852
- compositeFlat.addBrick(yield SurveyHelper.createCommentFlat(otherPoint, this.question, this.controller, {
7853
- fieldName: this.question.id + '_comment' + index,
7854
- rows: SurveyHelper.OTHER_ROWS_COUNT,
7855
- value: this.question.comment !== undefined && this.question.comment !== null ? this.question.comment : '',
7856
- shouldRenderBorders: settings.readOnlyCommentRenderMode === 'textarea',
7857
- isReadOnly: this.question.isReadOnly,
7858
- isMultiline: true,
7859
- }));
7851
+ compositeFlat.addBrick(yield this.generateItemComment(otherPoint, item));
7860
7852
  }
7861
7853
  return compositeFlat;
7862
7854
  });
@@ -7899,10 +7891,9 @@ class FlatSelectBase extends FlatQuestion {
7899
7891
  const flats = [];
7900
7892
  for (let row of rows) {
7901
7893
  const rowFlat = new CompositeBrick();
7902
- this.controller.pushMargins(this.controller.margins.left, this.controller.margins.right);
7903
7894
  for (let colIndex = 0; colIndex < row.length; colIndex++) {
7904
7895
  const item = row[colIndex];
7905
- this.controller.pushMargins(this.controller.margins.left, this.controller.margins.right);
7896
+ this.controller.pushMargins();
7906
7897
  SurveyHelper.setColumnMargins(this.controller, colCount, colIndex);
7907
7898
  currPoint.xLeft = this.controller.margins.left;
7908
7899
  const itemFlat = yield this.generateFlatComposite(currPoint, item, visibleChoices.indexOf(item));
@@ -8141,7 +8132,7 @@ class DropdownBrick extends PdfBrick {
8141
8132
  comboBox.fontSize = this.fontSize;
8142
8133
  comboBox.readOnly = this.question.isReadOnly;
8143
8134
  comboBox.isUnicode = SurveyHelper.isCustomFont(this.controller, comboBox.fontName);
8144
- comboBox.V = this.getCorrectedText(SurveyHelper.getDropdownQuestionValue(this.question));
8135
+ comboBox.V = this.getCorrectedText(this.question.readOnlyText || '');
8145
8136
  this.controller.doc.addField(comboBox);
8146
8137
  SurveyHelper.renderFlatBorders(this.controller, this);
8147
8138
  });
@@ -8155,27 +8146,33 @@ class FlatDropdown extends FlatQuestion {
8155
8146
  this.controller = controller;
8156
8147
  this.question = question;
8157
8148
  }
8149
+ generateItemComment(point) {
8150
+ return __awaiter(this, void 0, void 0, function* () {
8151
+ const commentModel = this.question.getCommentTextAreaModel(this.question.selectedItem);
8152
+ return yield SurveyHelper.createCommentFlat(point, this.question, this.controller, {
8153
+ fieldName: commentModel.id,
8154
+ rows: SurveyHelper.OTHER_ROWS_COUNT,
8155
+ value: commentModel.getTextValue(),
8156
+ shouldRenderBorders: settings.readOnlyCommentRenderMode === 'textarea',
8157
+ isReadOnly: this.question.isReadOnly,
8158
+ isMultiline: true,
8159
+ });
8160
+ });
8161
+ }
8158
8162
  generateFlatsContent(point) {
8159
8163
  return __awaiter(this, void 0, void 0, function* () {
8160
8164
  const valueBrick = !this.shouldRenderAsComment ? new DropdownBrick(this.question, this.controller, SurveyHelper.createTextFieldRect(point, this.controller)) : yield SurveyHelper.createCommentFlat(point, this.question, this.controller, {
8161
8165
  fieldName: this.question.id,
8162
8166
  shouldRenderBorders: settings.readOnlyTextRenderMode === 'input',
8163
- value: SurveyHelper.getDropdownQuestionValue(this.question),
8167
+ value: this.question.readOnlyText || '',
8164
8168
  isReadOnly: this.question.isReadOnly,
8165
8169
  placeholder: SurveyHelper.getLocString(this.question.locPlaceholder)
8166
8170
  });
8167
8171
  const compositeFlat = new CompositeBrick(valueBrick);
8168
- if (this.question.isOtherSelected) {
8172
+ if (this.question.isShowingChoiceComment) {
8169
8173
  const otherPoint = SurveyHelper.createPoint(compositeFlat);
8170
8174
  otherPoint.yTop += this.controller.unitHeight * SurveyHelper.GAP_BETWEEN_ROWS;
8171
- compositeFlat.addBrick(yield SurveyHelper.createCommentFlat(otherPoint, this.question, this.controller, {
8172
- fieldName: this.question.id + '_comment',
8173
- rows: SurveyHelper.OTHER_ROWS_COUNT,
8174
- value: this.question.comment !== undefined && this.question.comment !== null ? this.question.comment : '',
8175
- shouldRenderBorders: settings.readOnlyCommentRenderMode === 'textarea',
8176
- isReadOnly: this.question.isReadOnly,
8177
- isMultiline: true,
8178
- }));
8175
+ compositeFlat.addBrick(yield this.generateItemComment(otherPoint));
8179
8176
  }
8180
8177
  return [compositeFlat];
8181
8178
  });
@@ -8907,10 +8904,10 @@ class FlatMatrix extends FlatQuestion {
8907
8904
  }
8908
8905
  }
8909
8906
  FlatMatrix.GAP_BETWEEN_ROWS = 0.5;
8910
- class FlatMatrixRow extends FlatRadiogroup {
8907
+ class FlatMatrixRow {
8911
8908
  constructor(survey, question, controller, row, rowIndex, key, isFirst = false, isVertical = false, rowTitleWidth, columnWidth) {
8912
- super(survey, question, controller);
8913
8909
  this.survey = survey;
8910
+ this.question = question;
8914
8911
  this.controller = controller;
8915
8912
  this.row = row;
8916
8913
  this.rowIndex = rowIndex;
@@ -8919,7 +8916,6 @@ class FlatMatrixRow extends FlatRadiogroup {
8919
8916
  this.isVertical = isVertical;
8920
8917
  this.rowTitleWidth = rowTitleWidth;
8921
8918
  this.columnWidth = columnWidth;
8922
- this.questionMatrix = question;
8923
8919
  }
8924
8920
  generateFlatsContent(point) {
8925
8921
  return __awaiter(this, void 0, void 0, function* () {
@@ -8928,25 +8924,40 @@ class FlatMatrixRow extends FlatRadiogroup {
8928
8924
  yield this.generateFlatsHorizontallyCells(point);
8929
8925
  });
8930
8926
  }
8927
+ generateFlatItem(rect, item, index, key, context = {}) {
8928
+ const fieldName = this.question.id + key;
8929
+ const isChecked = this.row.isChecked(item);
8930
+ if (this.question.isMultiSelect) {
8931
+ return new CheckItemBrick(this.controller, rect, fieldName + 'index' + index, { question: this.question, index, checked: isChecked, item, readOnly: this.question.isReadOnly });
8932
+ }
8933
+ else {
8934
+ if (index === 0) {
8935
+ this.radioGroupWrap = new RadioGroupWrap(fieldName, this.controller, Object.assign({ readOnly: this.question.isReadOnly, question: this.question }, context));
8936
+ this.question.pdfRadioGroupWrap = this.radioGroupWrap;
8937
+ }
8938
+ else if (typeof this.radioGroupWrap === 'undefined') {
8939
+ this.radioGroupWrap = this.question.pdfRadioGroupWrap;
8940
+ }
8941
+ return new RadioItemBrick(this.controller, rect, { question: this.question, index: index, checked: isChecked, item: item }, this.radioGroupWrap);
8942
+ }
8943
+ }
8931
8944
  generateTextComposite(point, column, index) {
8932
8945
  return __awaiter(this, void 0, void 0, function* () {
8933
8946
  const currPoint = SurveyHelper.clone(point);
8934
- const checked = this.row.value == column.value;
8935
8947
  const itemRect = SurveyHelper.createRect(currPoint, SurveyHelper.getPageAvailableWidth(this.controller), this.controller.unitHeight);
8936
- const radioFlat = this.generateFlatItem(itemRect, column, index, this.key, checked, { row: this.row, rowIndex: this.rowIndex });
8948
+ const radioFlat = this.generateFlatItem(itemRect, column, index, this.key, { row: this.row, rowIndex: this.rowIndex });
8937
8949
  currPoint.yTop = radioFlat.yBot + this.controller.unitHeight * SurveyHelper.GAP_BETWEEN_ITEM_TEXT;
8938
- const cellTextFlat = yield SurveyHelper.createTextFlat(currPoint, this.questionMatrix, this.controller, this.questionMatrix.getCellDisplayLocText(this.row.name, column), TextBrick);
8950
+ const cellTextFlat = yield SurveyHelper.createTextFlat(currPoint, this.question, this.controller, this.question.getCellDisplayLocText(this.row.name, column), TextBrick);
8939
8951
  return new CompositeBrick(radioFlat, cellTextFlat);
8940
8952
  });
8941
8953
  }
8942
- generateItemCompoiste(point, column, index) {
8954
+ generateItemComposite(point, column, index) {
8943
8955
  return __awaiter(this, void 0, void 0, function* () {
8944
8956
  const currPoint = SurveyHelper.clone(point);
8945
- const checked = this.row.value == column.value;
8946
8957
  const itemRect = SurveyHelper.createRect(currPoint, this.controller.unitHeight, this.controller.unitHeight);
8947
- const radioFlat = this.generateFlatItem(SurveyHelper.moveRect(SurveyHelper.scaleRect(itemRect, SurveyHelper.SELECT_ITEM_FLAT_SCALE), itemRect.xLeft), column, index, this.key, checked, { row: this.row, rowIndex: this.rowIndex });
8958
+ const radioFlat = this.generateFlatItem(SurveyHelper.moveRect(SurveyHelper.scaleRect(itemRect, SurveyHelper.SELECT_ITEM_FLAT_SCALE), itemRect.xLeft), column, index, this.key, { row: this.row, rowIndex: this.rowIndex });
8948
8959
  currPoint.xLeft = radioFlat.xRight + this.controller.unitWidth * SurveyHelper.GAP_BETWEEN_ITEM_TEXT;
8949
- const radioText = yield SurveyHelper.createTextFlat(currPoint, this.questionMatrix, this.controller, column.locText, TextBrick);
8960
+ const radioText = yield SurveyHelper.createTextFlat(currPoint, this.question, this.controller, column.locText, TextBrick);
8950
8961
  return new CompositeBrick(radioFlat, radioText);
8951
8962
  });
8952
8963
  }
@@ -8954,26 +8965,26 @@ class FlatMatrixRow extends FlatRadiogroup {
8954
8965
  return __awaiter(this, void 0, void 0, function* () {
8955
8966
  const cells = [];
8956
8967
  const currPoint = SurveyHelper.clone(point);
8957
- if (this.questionMatrix.hasRows) {
8968
+ if (this.question.hasRows) {
8958
8969
  this.controller.pushMargins();
8959
8970
  currPoint.xLeft = this.controller.margins.left;
8960
8971
  this.controller.margins.right += (SurveyHelper.getPageAvailableWidth(this.controller) - this.rowTitleWidth);
8961
- cells.push(yield SurveyHelper.createTextFlat(currPoint, this.questionMatrix, this.controller, this.row.locText, TextBrick));
8972
+ cells.push(yield SurveyHelper.createTextFlat(currPoint, this.question, this.controller, this.row.locText, TextBrick));
8962
8973
  currPoint.xLeft += this.rowTitleWidth + this.controller.unitWidth * SurveyHelper.GAP_BETWEEN_COLUMNS;
8963
8974
  this.controller.popMargins();
8964
8975
  }
8965
- for (let i = 0; i < this.questionMatrix.visibleColumns.length; i++) {
8966
- const column = this.questionMatrix.visibleColumns[i];
8967
- const checked = this.row.value == column.value;
8976
+ for (let i = 0; i < this.question.visibleColumns.length; i++) {
8977
+ const column = this.question.visibleColumns[i];
8978
+ this.row.value == column.value;
8968
8979
  this.controller.pushMargins();
8969
8980
  this.controller.margins.left = currPoint.xLeft;
8970
8981
  this.controller.margins.right += (SurveyHelper.getPageAvailableWidth(this.controller) - this.columnWidth);
8971
- if (this.questionMatrix.hasCellText) {
8982
+ if (this.question.hasCellText) {
8972
8983
  cells.push(yield this.generateTextComposite(currPoint, column, i));
8973
8984
  }
8974
8985
  else {
8975
8986
  const itemRect = SurveyHelper.createRect(currPoint, this.controller.unitHeight, this.controller.unitHeight);
8976
- cells.push(this.generateFlatItem(SurveyHelper.moveRect(SurveyHelper.scaleRect(itemRect, SurveyHelper.SELECT_ITEM_FLAT_SCALE), currPoint.xLeft), column, i, this.key, checked, { row: this.row, rowIndex: this.rowIndex }));
8987
+ cells.push(this.generateFlatItem(SurveyHelper.moveRect(SurveyHelper.scaleRect(itemRect, SurveyHelper.SELECT_ITEM_FLAT_SCALE), currPoint.xLeft), column, i, this.key, { row: this.row, rowIndex: this.rowIndex }));
8977
8988
  }
8978
8989
  currPoint.xLeft += this.columnWidth + this.controller.unitWidth * SurveyHelper.GAP_BETWEEN_COLUMNS;
8979
8990
  this.controller.popMargins();
@@ -8986,17 +8997,28 @@ class FlatMatrixRow extends FlatRadiogroup {
8986
8997
  return __awaiter(this, void 0, void 0, function* () {
8987
8998
  const cells = [];
8988
8999
  const currPoint = SurveyHelper.clone(point);
8989
- if (this.questionMatrix.hasRows) {
8990
- const rowTextFlat = yield SurveyHelper.createTextFlat(currPoint, this.questionMatrix, this.controller, this.row.locText, TextBrick);
9000
+ if (this.question.hasRows) {
9001
+ const rowTextFlat = yield SurveyHelper.createTextFlat(currPoint, this.question, this.controller, this.row.locText, TextBrick);
8991
9002
  currPoint.yTop = rowTextFlat.yBot + FlatQuestion.CONTENT_GAP_VERT_SCALE * this.controller.unitHeight;
8992
9003
  cells.push(rowTextFlat);
8993
9004
  }
8994
- this.generateFlatComposite = (this.questionMatrix.hasCellText) ? this.generateTextComposite : this.generateItemCompoiste;
8995
- cells.push(...yield this.generateVerticallyItems(currPoint, this.questionMatrix.visibleColumns));
9005
+ cells.push(...yield this.generateVerticallyItems(currPoint, this.question.visibleColumns));
8996
9006
  const compositeBrick = new CompositeBrick(...cells);
8997
9007
  return [compositeBrick, SurveyHelper.createRowlineFlat(SurveyHelper.createPoint(compositeBrick), this.controller)];
8998
9008
  });
8999
9009
  }
9010
+ generateVerticallyItems(point, itemValues) {
9011
+ return __awaiter(this, void 0, void 0, function* () {
9012
+ const currPoint = SurveyHelper.clone(point);
9013
+ const flats = [];
9014
+ for (let i = 0; i < itemValues.length; i++) {
9015
+ const itemFlat = yield ((this.question.hasCellText) ? this.generateTextComposite : this.generateItemComposite).call(this, currPoint, itemValues[i], i);
9016
+ currPoint.yTop = itemFlat.yBot + SurveyHelper.GAP_BETWEEN_ROWS * this.controller.unitHeight;
9017
+ flats.push(itemFlat);
9018
+ }
9019
+ return flats;
9020
+ });
9021
+ }
9000
9022
  }
9001
9023
  Serializer.removeProperty('matrix', 'renderAs');
9002
9024
  Serializer.addProperty('matrix', {
@@ -9353,7 +9375,7 @@ class CustomBrick extends PdfBrick {
9353
9375
  }
9354
9376
  }
9355
9377
 
9356
- checkLibraryVersion(`${"2.2.5"}`, 'survey-pdf');
9378
+ checkLibraryVersion(`${"2.3.0"}`, 'survey-pdf');
9357
9379
 
9358
9380
  export { BooleanItemBrick, CheckItemBrick, CheckboxItemBrick, CompositeBrick, CustomBrick, DocController, DocOptions, DrawCanvas, DropdownBrick, EmptyBrick, EventHandler, FlatBooleanCheckbox as FlatBoolean, FlatCheckbox, FlatComment, FlatCustomModel, FlatDropdown, FlatExpression, FlatFile, FlatHTML, FlatImage, FlatImagePicker, FlatMatrix, FlatMatrixDynamic, FlatMatrixMultiple, FlatMultipleText, FlatPanelDynamic, FlatQuestion, FlatQuestionDefault, FlatRadiogroup, FlatRanking, FlatRating, FlatRepository, FlatSelectBase, FlatSignaturePad, FlatSlider, FlatSurvey, FlatTextbox, HTMLBrick, HorizontalAlign, ImageBrick, LinkBrick, PagePacker, PdfBrick, RadioItemBrick, RankingItemBrick, RowlineBrick, SurveyHelper, SurveyPDF, TextBoldBrick, TextBrick, TextFieldBrick, TitlePanelBrick, VerticalAlign };
9359
9381
  //# sourceMappingURL=survey.pdf.mjs.map