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.
- package/fesm/survey.pdf.fonts.mjs +1 -1
- package/fesm/survey.pdf.mjs +27 -13
- package/fesm/survey.pdf.mjs.map +1 -1
- package/package.json +2 -2
- package/survey.pdf.fonts.js +1 -1
- package/survey.pdf.fonts.min.js.LICENSE.txt +1 -1
- package/survey.pdf.js +28 -14
- package/survey.pdf.js.map +1 -1
- package/survey.pdf.min.js +1 -1
- package/survey.pdf.min.js.LICENSE.txt +1 -1
- package/typings/doc_controller.d.ts +20 -5
- package/typings/event_handler/draw_canvas.d.ts +4 -0
- package/typings/survey.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "survey-pdf",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "survey.pdf.js is a SurveyJS PDF Library. It is a easy way to export SurveyJS surveys to PDF. It uses JSON for survey metadata.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Survey",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"typings": "./typings/entries/pdf.d.ts",
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"survey-core": "2.0.
|
|
22
|
+
"survey-core": "2.0.8"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"jspdf": "^2.3.0 || ^3"
|
package/survey.pdf.fonts.js
CHANGED
package/survey.pdf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* surveyjs - SurveyJS PDF library v2.0.
|
|
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
|
*/
|
|
@@ -1015,9 +1015,9 @@ var DocOptions = /** @class */ (function () {
|
|
|
1015
1015
|
}());
|
|
1016
1016
|
|
|
1017
1017
|
/**
|
|
1018
|
-
* The `DocController` object includes an API that allows you to configure
|
|
1018
|
+
* The `DocController` object includes an API that allows you to configure main PDF document properties (font, margins, page width and height).
|
|
1019
1019
|
*
|
|
1020
|
-
* [View Demo](https://surveyjs.io/pdf-generator/examples/
|
|
1020
|
+
* [View Demo](https://surveyjs.io/pdf-generator/examples/change-font-in-pdf-form/ (linkStyle))
|
|
1021
1021
|
*/
|
|
1022
1022
|
var DocController = /** @class */ (function (_super) {
|
|
1023
1023
|
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(DocController, _super);
|
|
@@ -1047,6 +1047,14 @@ var DocController = /** @class */ (function (_super) {
|
|
|
1047
1047
|
_this.marginsStack = [];
|
|
1048
1048
|
return _this;
|
|
1049
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Adds a custom font to the PDF Generator.
|
|
1052
|
+
*
|
|
1053
|
+
* [View Demo](https://surveyjs.io/pdf-generator/examples/change-font-in-pdf-form/ (linkStyle))
|
|
1054
|
+
* @param fontName A custom name that you will use to apply the custom font.
|
|
1055
|
+
* @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.
|
|
1056
|
+
* @param fontStyle The style of the custom font: `"normal"`, `"bold"`, `"italic"`, or `"bolditalic"`.
|
|
1057
|
+
*/
|
|
1050
1058
|
DocController.addFont = function (fontName, base64, fontStyle) {
|
|
1051
1059
|
var font = DocController.customFonts[fontName];
|
|
1052
1060
|
if (!font) {
|
|
@@ -1553,7 +1561,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1553
1561
|
|
|
1554
1562
|
|
|
1555
1563
|
|
|
1556
|
-
(0,survey_core__WEBPACK_IMPORTED_MODULE_51__.checkLibraryVersion)("".concat("2.0.
|
|
1564
|
+
(0,survey_core__WEBPACK_IMPORTED_MODULE_51__.checkLibraryVersion)("".concat("2.0.8"), 'survey-pdf');
|
|
1557
1565
|
|
|
1558
1566
|
|
|
1559
1567
|
/***/ }),
|
|
@@ -1785,6 +1793,8 @@ var DrawCanvas = /** @class */ (function () {
|
|
|
1785
1793
|
};
|
|
1786
1794
|
/**
|
|
1787
1795
|
* Draws a piece of text within the drawing area.
|
|
1796
|
+
*
|
|
1797
|
+
* [View Demo](https://surveyjs.io/pdf-generator/examples/customize-header-and-footer-of-pdf-form/ (linkStyle))
|
|
1788
1798
|
* @param textOptions An [`IDrawTextOptions`](https://surveyjs.io/pdf-generator/documentation/api-reference/idrawtextoptions) object that configures the drawing.
|
|
1789
1799
|
*/
|
|
1790
1800
|
DrawCanvas.prototype.drawText = function (textOptions) {
|
|
@@ -1807,6 +1817,8 @@ var DrawCanvas = /** @class */ (function () {
|
|
|
1807
1817
|
};
|
|
1808
1818
|
/**
|
|
1809
1819
|
* Draws an image within the drawing area.
|
|
1820
|
+
*
|
|
1821
|
+
* [View Demo](https://surveyjs.io/pdf-generator/examples/customize-header-and-footer-of-pdf-form/ (linkStyle))
|
|
1810
1822
|
* @param imageOptions An [`IDrawImageOptions`](https://surveyjs.io/pdf-generator/documentation/api-reference/idrawimageoptions) object that configures drawing.
|
|
1811
1823
|
*/
|
|
1812
1824
|
DrawCanvas.prototype.drawImage = function (imageOptions) {
|
|
@@ -2414,8 +2426,8 @@ var FlatFile = /** @class */ (function (_super) {
|
|
|
2414
2426
|
});
|
|
2415
2427
|
});
|
|
2416
2428
|
};
|
|
2417
|
-
FlatFile.prototype.addLine = function (rowsFlats, currPoint, index) {
|
|
2418
|
-
if (index !==
|
|
2429
|
+
FlatFile.prototype.addLine = function (rowsFlats, currPoint, index, previewValue) {
|
|
2430
|
+
if (index !== previewValue.length - 1) {
|
|
2419
2431
|
rowsFlats[rowsFlats.length - 1].addBrick(_helper_survey__WEBPACK_IMPORTED_MODULE_5__.SurveyHelper.createRowlineFlat(currPoint, this.controller));
|
|
2420
2432
|
currPoint.yTop += _helper_survey__WEBPACK_IMPORTED_MODULE_5__.SurveyHelper.EPSILON;
|
|
2421
2433
|
rowsFlats.push(new _pdf_render_pdf_composite__WEBPACK_IMPORTED_MODULE_4__.CompositeBrick());
|
|
@@ -2430,11 +2442,12 @@ var FlatFile = /** @class */ (function (_super) {
|
|
|
2430
2442
|
};
|
|
2431
2443
|
FlatFile.prototype.generateFlatsContent = function (point) {
|
|
2432
2444
|
return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
|
|
2433
|
-
var rowsFlats, currPoint, yBot, i, item, canPreviewImage, _a, availableWidth, compositeWidth, itemFlat, itemFlat;
|
|
2445
|
+
var previewValue, rowsFlats, currPoint, yBot, i, item, canPreviewImage, _a, availableWidth, compositeWidth, itemFlat, itemFlat;
|
|
2434
2446
|
return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_b) {
|
|
2435
2447
|
switch (_b.label) {
|
|
2436
2448
|
case 0:
|
|
2437
|
-
|
|
2449
|
+
previewValue = this.question.showPreview ? this.question.previewValue : this.question.value;
|
|
2450
|
+
if (!(!previewValue || previewValue.length === 0)) return [3 /*break*/, 2];
|
|
2438
2451
|
return [4 /*yield*/, _helper_survey__WEBPACK_IMPORTED_MODULE_5__.SurveyHelper.createTextFlat(point, this.question, this.controller, this.question.noFileChosenCaption, _pdf_render_pdf_text__WEBPACK_IMPORTED_MODULE_3__.TextBrick)];
|
|
2439
2452
|
case 1: return [2 /*return*/, [_b.sent()]];
|
|
2440
2453
|
case 2:
|
|
@@ -2444,12 +2457,12 @@ var FlatFile = /** @class */ (function (_super) {
|
|
|
2444
2457
|
i = 0;
|
|
2445
2458
|
_b.label = 3;
|
|
2446
2459
|
case 3:
|
|
2447
|
-
if (!(i <
|
|
2448
|
-
item = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({},
|
|
2460
|
+
if (!(i < previewValue.length)) return [3 /*break*/, 12];
|
|
2461
|
+
item = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, previewValue[i]);
|
|
2449
2462
|
canPreviewImage = _helper_survey__WEBPACK_IMPORTED_MODULE_5__.SurveyHelper.canPreviewImage(this.question, item, item.content);
|
|
2450
2463
|
if (!canPreviewImage) return [3 /*break*/, 5];
|
|
2451
2464
|
_a = item;
|
|
2452
|
-
return [4 /*yield*/, _helper_survey__WEBPACK_IMPORTED_MODULE_5__.SurveyHelper.getCorrectedImageSize(this.controller, { imageWidth: this.question.imageWidth, imageHeight: this.question.imageHeight, imageLink:
|
|
2465
|
+
return [4 /*yield*/, _helper_survey__WEBPACK_IMPORTED_MODULE_5__.SurveyHelper.getCorrectedImageSize(this.controller, { imageWidth: this.question.imageWidth, imageHeight: this.question.imageHeight, imageLink: previewValue[i].content, defaultImageWidth: 200, defaultImageHeight: 150 })];
|
|
2453
2466
|
case 4:
|
|
2454
2467
|
_a.imageSize = _b.sent();
|
|
2455
2468
|
_b.label = 5;
|
|
@@ -2463,7 +2476,7 @@ var FlatFile = /** @class */ (function (_super) {
|
|
|
2463
2476
|
if (availableWidth < compositeWidth) {
|
|
2464
2477
|
currPoint.xLeft = point.xLeft;
|
|
2465
2478
|
currPoint.yTop = yBot;
|
|
2466
|
-
this.addLine(rowsFlats, currPoint, i);
|
|
2479
|
+
this.addLine(rowsFlats, currPoint, i, previewValue);
|
|
2467
2480
|
}
|
|
2468
2481
|
this.controller.pushMargins(currPoint.xLeft, this.controller.paperWidth - currPoint.xLeft - compositeWidth);
|
|
2469
2482
|
return [4 /*yield*/, this.generateFlatItem(currPoint, item)];
|
|
@@ -2478,7 +2491,7 @@ var FlatFile = /** @class */ (function (_super) {
|
|
|
2478
2491
|
if (availableWidth < this.controller.unitWidth) {
|
|
2479
2492
|
currPoint.xLeft = point.xLeft;
|
|
2480
2493
|
currPoint.yTop = yBot;
|
|
2481
|
-
this.addLine(rowsFlats, currPoint, i);
|
|
2494
|
+
this.addLine(rowsFlats, currPoint, i, previewValue);
|
|
2482
2495
|
}
|
|
2483
2496
|
return [4 /*yield*/, this.generateFlatItem(currPoint, item)];
|
|
2484
2497
|
case 9:
|
|
@@ -12437,8 +12450,9 @@ var SurveyPDF = /** @class */ (function (_super) {
|
|
|
12437
12450
|
});
|
|
12438
12451
|
};
|
|
12439
12452
|
/**
|
|
12440
|
-
* An asynchronous method that starts download of the generated PDF file in the web browser.
|
|
12453
|
+
* An asynchronous method that starts the download of the generated PDF file in the web browser.
|
|
12441
12454
|
*
|
|
12455
|
+
* [View Demo](https://surveyjs.io/pdf-generator/examples/save-completed-forms-as-pdf-files/ (linkStyle))
|
|
12442
12456
|
* @param fileName *(Optional)* A file name with the ".pdf" extension. Default value: `"survey_result.pdf"`.
|
|
12443
12457
|
*/
|
|
12444
12458
|
SurveyPDF.prototype.save = function () {
|