survey-pdf 2.0.6 → 2.0.8

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.0.6
2
+ * surveyjs - SurveyJS PDF library v2.0.8
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.0.6
2
+ * surveyjs - SurveyJS PDF library v2.0.8
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
  */
@@ -6221,9 +6221,9 @@ class DocOptions {
6221
6221
  DocOptions.MM_TO_PT = 72 / 25.4;
6222
6222
  DocOptions.FONT_SIZE = 14;
6223
6223
  /**
6224
- * The `DocController` object includes an API that allows you to configure the resulting PDF document. You can access this object within functions that handle the `SurveyPDF`'s [`onRender...`](https://surveyjs.io/pdf-generator/documentation/api-reference/surveypdf#onRenderFooter) events.
6224
+ * The `DocController` object includes an API that allows you to configure main PDF document properties (font, margins, page width and height).
6225
6225
  *
6226
- * [View Demo](https://surveyjs.io/pdf-generator/examples/how-to-use-adorners-in-pdf-forms/ (linkStyle))
6226
+ * [View Demo](https://surveyjs.io/pdf-generator/examples/change-font-in-pdf-form/ (linkStyle))
6227
6227
  */
6228
6228
  class DocController extends DocOptions {
6229
6229
  constructor(options = {}) {
@@ -6250,6 +6250,14 @@ class DocController extends DocOptions {
6250
6250
  this._fontStyle = 'normal';
6251
6251
  this.marginsStack = [];
6252
6252
  }
6253
+ /**
6254
+ * Adds a custom font to the PDF Generator.
6255
+ *
6256
+ * [View Demo](https://surveyjs.io/pdf-generator/examples/change-font-in-pdf-form/ (linkStyle))
6257
+ * @param fontName A custom name that you will use to apply the custom font.
6258
+ * @param base64 The custom font as a Base64-encoded string. To encode your font to Base64, obtain it as a TTF file and use any TTF-to-Base64 online converter.
6259
+ * @param fontStyle The style of the custom font: `"normal"`, `"bold"`, `"italic"`, or `"bolditalic"`.
6260
+ */
6253
6261
  static addFont(fontName, base64, fontStyle) {
6254
6262
  let font = DocController.customFonts[fontName];
6255
6263
  if (!font) {
@@ -7355,6 +7363,8 @@ class DrawCanvas {
7355
7363
  }
7356
7364
  /**
7357
7365
  * Draws a piece of text within the drawing area.
7366
+ *
7367
+ * [View Demo](https://surveyjs.io/pdf-generator/examples/customize-header-and-footer-of-pdf-form/ (linkStyle))
7358
7368
  * @param textOptions An [`IDrawTextOptions`](https://surveyjs.io/pdf-generator/documentation/api-reference/idrawtextoptions) object that configures the drawing.
7359
7369
  */
7360
7370
  drawText(textOptions) {
@@ -7377,6 +7387,8 @@ class DrawCanvas {
7377
7387
  }
7378
7388
  /**
7379
7389
  * Draws an image within the drawing area.
7390
+ *
7391
+ * [View Demo](https://surveyjs.io/pdf-generator/examples/customize-header-and-footer-of-pdf-form/ (linkStyle))
7380
7392
  * @param imageOptions An [`IDrawImageOptions`](https://surveyjs.io/pdf-generator/documentation/api-reference/idrawimageoptions) object that configures drawing.
7381
7393
  */
7382
7394
  drawImage(imageOptions) {
@@ -7655,8 +7667,9 @@ class SurveyPDF extends SurveyModel {
7655
7667
  });
7656
7668
  }
7657
7669
  /**
7658
- * An asynchronous method that starts download of the generated PDF file in the web browser.
7670
+ * An asynchronous method that starts the download of the generated PDF file in the web browser.
7659
7671
  *
7672
+ * [View Demo](https://surveyjs.io/pdf-generator/examples/save-completed-forms-as-pdf-files/ (linkStyle))
7660
7673
  * @param fileName *(Optional)* A file name with the ".pdf" extension. Default value: `"survey_result.pdf"`.
7661
7674
  */
7662
7675
  save() {
@@ -8200,8 +8213,8 @@ class FlatFile extends FlatQuestion {
8200
8213
  return compositeFlat;
8201
8214
  });
8202
8215
  }
8203
- addLine(rowsFlats, currPoint, index) {
8204
- if (index !== this.question.previewValue.length - 1) {
8216
+ addLine(rowsFlats, currPoint, index, previewValue) {
8217
+ if (index !== previewValue.length - 1) {
8205
8218
  rowsFlats[rowsFlats.length - 1].addBrick(SurveyHelper.createRowlineFlat(currPoint, this.controller));
8206
8219
  currPoint.yTop += SurveyHelper.EPSILON;
8207
8220
  rowsFlats.push(new CompositeBrick());
@@ -8214,17 +8227,18 @@ class FlatFile extends FlatQuestion {
8214
8227
  }
8215
8228
  generateFlatsContent(point) {
8216
8229
  return __awaiter(this, void 0, void 0, function* () {
8217
- if (this.question.previewValue.length === 0) {
8230
+ const previewValue = this.question.showPreview ? this.question.previewValue : this.question.value;
8231
+ if (!previewValue || previewValue.length === 0) {
8218
8232
  return [yield SurveyHelper.createTextFlat(point, this.question, this.controller, this.question.noFileChosenCaption, TextBrick)];
8219
8233
  }
8220
8234
  const rowsFlats = [new CompositeBrick()];
8221
8235
  const currPoint = SurveyHelper.clone(point);
8222
8236
  let yBot = currPoint.yTop;
8223
- for (let i = 0; i < this.question.previewValue.length; i++) {
8224
- let item = Object.assign({}, this.question.previewValue[i]);
8237
+ for (let i = 0; i < previewValue.length; i++) {
8238
+ let item = Object.assign({}, previewValue[i]);
8225
8239
  const canPreviewImage = SurveyHelper.canPreviewImage(this.question, item, item.content);
8226
8240
  if (canPreviewImage) {
8227
- item.imageSize = yield SurveyHelper.getCorrectedImageSize(this.controller, { imageWidth: this.question.imageWidth, imageHeight: this.question.imageHeight, imageLink: this.question.previewValue[i].content, defaultImageWidth: 200, defaultImageHeight: 150 });
8241
+ item.imageSize = yield SurveyHelper.getCorrectedImageSize(this.controller, { imageWidth: this.question.imageWidth, imageHeight: this.question.imageHeight, imageLink: previewValue[i].content, defaultImageWidth: 200, defaultImageHeight: 150 });
8228
8242
  }
8229
8243
  const availableWidth = this.controller.paperWidth -
8230
8244
  this.controller.margins.right - currPoint.xLeft;
@@ -8233,7 +8247,7 @@ class FlatFile extends FlatQuestion {
8233
8247
  if (availableWidth < compositeWidth) {
8234
8248
  currPoint.xLeft = point.xLeft;
8235
8249
  currPoint.yTop = yBot;
8236
- this.addLine(rowsFlats, currPoint, i);
8250
+ this.addLine(rowsFlats, currPoint, i, previewValue);
8237
8251
  }
8238
8252
  this.controller.pushMargins(currPoint.xLeft, this.controller.paperWidth - currPoint.xLeft - compositeWidth);
8239
8253
  const itemFlat = yield this.generateFlatItem(currPoint, item);
@@ -8246,7 +8260,7 @@ class FlatFile extends FlatQuestion {
8246
8260
  if (availableWidth < this.controller.unitWidth) {
8247
8261
  currPoint.xLeft = point.xLeft;
8248
8262
  currPoint.yTop = yBot;
8249
- this.addLine(rowsFlats, currPoint, i);
8263
+ this.addLine(rowsFlats, currPoint, i, previewValue);
8250
8264
  }
8251
8265
  const itemFlat = yield this.generateFlatItem(currPoint, item);
8252
8266
  rowsFlats[rowsFlats.length - 1].addBrick(itemFlat);
@@ -9263,7 +9277,7 @@ class CustomBrick extends PdfBrick {
9263
9277
  }
9264
9278
  }
9265
9279
 
9266
- checkLibraryVersion(`${"2.0.6"}`, 'survey-pdf');
9280
+ checkLibraryVersion(`${"2.0.8"}`, 'survey-pdf');
9267
9281
 
9268
9282
  export { BooleanItemBrick, CheckItemBrick, CheckboxItemBrick, CommentBrick, 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, FlatSurvey, FlatTextbox, HTMLBrick, HorizontalAlign, ImageBrick, LinkBrick, PagePacker, PdfBrick, RadioItemBrick, RankingItemBrick, RowlineBrick, SurveyHelper, SurveyPDF, TextBoldBrick, TextBoxBrick, TextBrick, TextFieldBrick, TitlePanelBrick, VerticalAlign };
9269
9283
  //# sourceMappingURL=survey.pdf.mjs.map