survey-pdf 2.0.7 → 2.0.9

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.
Files changed (36) hide show
  1. package/fesm/pdf-form-filler-shared.mjs +191 -0
  2. package/fesm/pdf-form-filler-shared.mjs.map +1 -0
  3. package/fesm/pdf-form-filler.mjs +26 -0
  4. package/fesm/pdf-form-filler.mjs.map +1 -0
  5. package/fesm/pdf-form-filler.node.mjs +27 -0
  6. package/fesm/pdf-form-filler.node.mjs.map +1 -0
  7. package/fesm/survey.pdf.fonts.mjs +1 -1
  8. package/fesm/survey.pdf.mjs +18 -5
  9. package/fesm/survey.pdf.mjs.map +1 -1
  10. package/package.json +10 -2
  11. package/pdf-form-filler.js +582 -0
  12. package/pdf-form-filler.js.map +1 -0
  13. package/pdf-form-filler.min.js +2 -0
  14. package/pdf-form-filler.min.js.LICENSE.txt +5 -0
  15. package/pdf-form-filler.node.js +605 -0
  16. package/pdf-form-filler.node.js.map +1 -0
  17. package/pdf-form-filler.node.min.js +2 -0
  18. package/pdf-form-filler.node.min.js.LICENSE.txt +5 -0
  19. package/survey.pdf.fonts.js +1 -1
  20. package/survey.pdf.fonts.min.js.LICENSE.txt +1 -1
  21. package/survey.pdf.js +18 -5
  22. package/survey.pdf.js.map +1 -1
  23. package/survey.pdf.min.js +1 -1
  24. package/survey.pdf.min.js.LICENSE.txt +1 -1
  25. package/typings/doc_controller.d.ts +20 -5
  26. package/typings/entries/forms-node.d.ts +3 -0
  27. package/typings/entries/forms.d.ts +3 -0
  28. package/typings/event_handler/draw_canvas.d.ts +4 -0
  29. package/typings/pdf_forms/adapters/adapter.d.ts +3 -0
  30. package/typings/pdf_forms/adapters/pdf-lib.d.ts +6 -0
  31. package/typings/pdf_forms/adapters/pdfjs.d.ts +6 -0
  32. package/typings/pdf_forms/forms-base.d.ts +32 -0
  33. package/typings/pdf_forms/forms-node.d.ts +4 -0
  34. package/typings/pdf_forms/forms.d.ts +4 -0
  35. package/typings/pdf_forms/map.d.ts +7 -0
  36. package/typings/survey.d.ts +2 -1
@@ -0,0 +1,2 @@
1
+ /*! For license information please see pdf-form-filler.node.min.js.LICENSE.txt */
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("fs")):"function"==typeof define&&define.amd?define("PDFFormFiller",["fs"],e):"object"==typeof exports?exports.PDFFormFiller=e(require("fs")):t.PDFFormFiller=e(t.fs)}(this,(t=>(()=>{"use strict";var e={947:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};n.r(o),n.d(o,{PDFFormFiller:()=>l,PDFJSAdapter:()=>d,PDFLibAdapter:()=>p});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)};function a(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{s(n.next(t))}catch(t){i(t)}}function u(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}s((n=n.apply(t,e||[])).next())}))}function u(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}const s=function(){function t(t){this.map=t,this.res={}}return t.prototype.mapDataRecursive=function(t,e){var r=this;if(null!=t)return"object"!=typeof t?Array.isArray(e)?void e.forEach((function(e){r.mapDataRecursive(t,e)})):void("object"!=typeof e?this.res[e]=t:this.res[e[t].field]=e[t].value):void(Array.isArray(t)?t.forEach((function(t,n){r.mapDataRecursive(t,Array.isArray(e)?e[n]:e)})):Object.keys(t).forEach((function(n){r.mapDataRecursive(t[n],e[n])})))},t.prototype.mapData=function(t){return this.res={},this.mapDataRecursive(t,this.map),this.res},t}();var c=function(){function t(t){void 0===t&&(t=null),t&&(this.data=t.data,this.fieldMap=t.fieldMap,this.pdfTemplate=t.pdfTemplate,this.pdfLibraryAdapter=t.pdfLibraryAdapter)}return t.prototype.getPDFBytes=function(){return a(this,void 0,void 0,(function(){var t,e;return u(this,(function(r){switch(r.label){case 0:return t=new s(this.fieldMap),e=t.mapData(this.data),[4,this.pdfLibraryAdapter.fillForm(this.pdfTemplate,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.raw=function(t){return a(this,void 0,void 0,(function(){var e,r;return u(this,(function(n){switch(n.label){case 0:return[4,this.getPDFBytes()];case 1:return e=n.sent(),t?"dataurlstring"==t?[2,"data:text/plain;base64,"+btoa(e)]:(r=new Blob([e],{type:"application/pdf"}),"blob"==t?[2,r]:"bloburl"==t?[2,URL.createObjectURL(r)]:[2,e]):[2,e]}}))}))},t.prototype.save=function(){return a(this,arguments,void 0,(function(t){var e;return void 0===t&&(t="survey_result.pdf"),u(this,(function(r){switch(r.label){case 0:return[4,this.getPDFBytes()];case 1:return e=r.sent(),[4,this.saveToFile(e,t)];case 2:return r.sent(),[2]}}))}))},t}(),f=n(947),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.saveToFile=function(t,e){return a(this,void 0,void 0,(function(){return u(this,(function(r){return[2,new Promise((function(r,n){(0,f.writeFile)(e,t,(function(t){t?n(t):r()}))}))]}))}))},e}(c),p=function(){function t(t){this.pdfLibrary=t}return t.prototype.fillForm=function(t,e){return a(this,void 0,void 0,(function(){var r,n,o,i,a,s,c;return u(this,(function(u){switch(u.label){case 0:return r=this.pdfLibrary,n=r.PDFDocument,o=r.PDFTextField,i=r.PDFCheckBox,a=r.PDFRadioGroup,s=r.PDFDropdown,[4,n.load(t)];case 1:return c=u.sent(),c.getForm().getFields().forEach((function(t){var r=t.getName(),n=e[r];null!=n&&(t instanceof o?t.setText(n):t instanceof i?n?t.check():t.uncheck():(t instanceof a||t instanceof s)&&t.select(n.toString()))})),[4,c.save()];case 2:return[2,u.sent()]}}))}))},t}(),d=function(){function t(t){this.pdfLibrary=t}return t.prototype.fillForm=function(t,e){return a(this,void 0,void 0,(function(){var r;return u(this,(function(n){switch(n.label){case 0:return[4,this.pdfLibrary.getDocument(t).promise];case 1:return[4,(r=n.sent()).getPage(1)];case 2:return[4,n.sent().getAnnotations()];case 3:return n.sent().forEach((function(t){if(null!=t.fieldType){var n=e[t.fieldName];if(n){if(t.radioButton&&t.buttonValue!=n)return;r.annotationStorage.setValue(t.id,{value:n})}}})),[4,r.saveDocument()];case 4:return[2,n.sent()]}}))}))},t}();return o})()));
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * surveyjs - SurveyJS PDF library v2.0.9
3
+ * Copyright (c) 2015-2025 Devsoft Baltic OÜ - http://surveyjs.io/
4
+ * License: MIT (http://www.opensource.org/licenses/mit-license.php)
5
+ */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS PDF library v2.0.7
2
+ * surveyjs - SurveyJS PDF library v2.0.9
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.7
2
+ * surveyjs - SurveyJS PDF library v2.0.9
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
  */
package/survey.pdf.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * surveyjs - SurveyJS PDF library v2.0.7
2
+ * surveyjs - SurveyJS PDF library v2.0.9
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 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.
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/how-to-use-adorners-in-pdf-forms/ (linkStyle))
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.7"), 'survey-pdf');
1564
+ (0,survey_core__WEBPACK_IMPORTED_MODULE_51__.checkLibraryVersion)("".concat("2.0.9"), '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) {
@@ -12438,8 +12450,9 @@ var SurveyPDF = /** @class */ (function (_super) {
12438
12450
  });
12439
12451
  };
12440
12452
  /**
12441
- * 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.
12442
12454
  *
12455
+ * [View Demo](https://surveyjs.io/pdf-generator/examples/save-completed-forms-as-pdf-files/ (linkStyle))
12443
12456
  * @param fileName *(Optional)* A file name with the ".pdf" extension. Default value: `"survey_result.pdf"`.
12444
12457
  */
12445
12458
  SurveyPDF.prototype.save = function () {