authscape 1.0.156 → 1.0.158

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/index.js CHANGED
@@ -1140,28 +1140,34 @@ var PageToPDF = function PageToPDF(_ref) {
1140
1140
  elementById = _ref.elementById,
1141
1141
  _ref$scale = _ref.scale,
1142
1142
  scale = _ref$scale === void 0 ? 2 : _ref$scale,
1143
+ _ref$onHideElements = _ref.onHideElements,
1144
+ onHideElements = _ref$onHideElements === void 0 ? null : _ref$onHideElements,
1143
1145
  _ref$fileName = _ref.fileName,
1144
1146
  fileName = _ref$fileName === void 0 ? "download" : _ref$fileName;
1145
1147
  var printElement = function printElement() {
1146
- var input = document.getElementById(elementById);
1147
- (0, _html2canvas["default"])(input, {
1148
- backgroundColor: null,
1149
- scale: scale
1150
- }).then(function (canvas) {
1151
- var imgData = canvas.toDataURL("image/png", 1.0);
1152
- var pdf = new _jspdf.jsPDF();
1153
- var pdfWidth = pdf.internal.pageSize.getWidth();
1154
- var pdfHeight = pdf.internal.pageSize.getHeight();
1155
- var imgWidth = canvas.width;
1156
- var imgHeight = canvas.height;
1157
- var scaleFactor = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight);
1158
- var scaledWidth = imgWidth * scaleFactor;
1159
- var scaledHeight = imgHeight * scaleFactor;
1160
- var x = (pdfWidth - scaledWidth) / 2;
1161
- var y = 0; // Set y coordinate to 0 to align to the top
1162
- pdf.addImage(imgData, "PNG", x, y, scaledWidth, scaledHeight);
1163
- pdf.save(fileName + ".pdf");
1164
- });
1148
+ onHideElements(true);
1149
+ setTimeout(function () {
1150
+ var input = document.getElementById(elementById);
1151
+ (0, _html2canvas["default"])(input, {
1152
+ backgroundColor: null,
1153
+ scale: scale
1154
+ }).then(function (canvas) {
1155
+ var imgData = canvas.toDataURL("image/png", 1.0);
1156
+ var pdf = new _jspdf.jsPDF();
1157
+ var pdfWidth = pdf.internal.pageSize.getWidth();
1158
+ var pdfHeight = pdf.internal.pageSize.getHeight();
1159
+ var imgWidth = canvas.width;
1160
+ var imgHeight = canvas.height;
1161
+ var scaleFactor = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight);
1162
+ var scaledWidth = imgWidth * scaleFactor;
1163
+ var scaledHeight = imgHeight * scaleFactor;
1164
+ var x = (pdfWidth - scaledWidth) / 2;
1165
+ var y = 0; // Set y coordinate to 0 to align to the top
1166
+ pdf.addImage(imgData, "PNG", x, y, scaledWidth, scaledHeight);
1167
+ pdf.save(fileName + ".pdf");
1168
+ });
1169
+ }, 2000);
1170
+ onHideElements(false);
1165
1171
  };
1166
1172
  return /*#__PURE__*/_react["default"].createElement(_Box["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
1167
1173
  startIcon: startIcon,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.156",
3
+ "version": "1.0.158",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,27 +5,35 @@ import { jsPDF } from "jspdf";
5
5
  import Button from "@mui/material/Button";
6
6
  import DownloadRoundedIcon from '@mui/icons-material/DownloadRounded';
7
7
 
8
- export const PageToPDF = ({buttonText = "Download", startIcon = <DownloadRoundedIcon/>, variant = "contained", elementById, scale = 2, fileName = "download"}) => {
8
+ export const PageToPDF = ({buttonText = "Download", startIcon = <DownloadRoundedIcon/>, variant = "contained", elementById, scale = 2, onHideElements = null, fileName = "download"}) => {
9
9
 
10
10
  const printElement = () => {
11
11
 
12
- const input = document.getElementById(elementById);
13
- html2canvas(input, {backgroundColor: null, scale: scale})
14
- .then((canvas) => {
15
- const imgData = canvas.toDataURL("image/png", 1.0);
16
- const pdf = new jsPDF();
17
- const pdfWidth = pdf.internal.pageSize.getWidth();
18
- const pdfHeight = pdf.internal.pageSize.getHeight();
19
- const imgWidth = canvas.width;
20
- const imgHeight = canvas.height;
21
- const scaleFactor = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight);
22
- const scaledWidth = imgWidth * scaleFactor;
23
- const scaledHeight = imgHeight * scaleFactor;
24
- const x = (pdfWidth - scaledWidth) / 2;
25
- const y = 0; // Set y coordinate to 0 to align to the top
26
- pdf.addImage(imgData, "PNG", x, y, scaledWidth, scaledHeight);
27
- pdf.save(fileName + ".pdf");
28
- })
12
+ onHideElements(true);
13
+
14
+ setTimeout(() => {
15
+
16
+ const input = document.getElementById(elementById);
17
+ html2canvas(input, {backgroundColor: null, scale: scale})
18
+ .then((canvas) => {
19
+ const imgData = canvas.toDataURL("image/png", 1.0);
20
+ const pdf = new jsPDF();
21
+ const pdfWidth = pdf.internal.pageSize.getWidth();
22
+ const pdfHeight = pdf.internal.pageSize.getHeight();
23
+ const imgWidth = canvas.width;
24
+ const imgHeight = canvas.height;
25
+ const scaleFactor = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight);
26
+ const scaledWidth = imgWidth * scaleFactor;
27
+ const scaledHeight = imgHeight * scaleFactor;
28
+ const x = (pdfWidth - scaledWidth) / 2;
29
+ const y = 0; // Set y coordinate to 0 to align to the top
30
+ pdf.addImage(imgData, "PNG", x, y, scaledWidth, scaledHeight);
31
+ pdf.save(fileName + ".pdf");
32
+ })
33
+
34
+ }, 2000);
35
+
36
+ onHideElements(false);
29
37
  }
30
38
 
31
39