authscape 1.0.156 → 1.0.159

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,9 +1140,30 @@ 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$showHideClassEle = _ref.showHideClassElements,
1144
+ showHideClassElements = _ref$showHideClassEle === void 0 ? [] : _ref$showHideClassEle,
1143
1145
  _ref$fileName = _ref.fileName,
1144
1146
  fileName = _ref$fileName === void 0 ? "download" : _ref$fileName;
1147
+ var onHideElements = function onHideElements() {
1148
+ for (var index = 0; index < showHideClassElements.length; index++) {
1149
+ var element = showHideClassElements[index];
1150
+ var className = document.getElementsByClassName(element);
1151
+ if (className != null) {
1152
+ className.style.display = "none";
1153
+ }
1154
+ }
1155
+ };
1156
+ var onShowElements = function onShowElements() {
1157
+ for (var index = 0; index < showHideClassElements.length; index++) {
1158
+ var element = showHideClassElements[index];
1159
+ var className = document.getElementsByClassName(element);
1160
+ if (className != null) {
1161
+ className.style.display = "block";
1162
+ }
1163
+ }
1164
+ };
1145
1165
  var printElement = function printElement() {
1166
+ onHideElements();
1146
1167
  var input = document.getElementById(elementById);
1147
1168
  (0, _html2canvas["default"])(input, {
1148
1169
  backgroundColor: null,
@@ -1162,6 +1183,7 @@ var PageToPDF = function PageToPDF(_ref) {
1162
1183
  pdf.addImage(imgData, "PNG", x, y, scaledWidth, scaledHeight);
1163
1184
  pdf.save(fileName + ".pdf");
1164
1185
  });
1186
+ onShowElements();
1165
1187
  };
1166
1188
  return /*#__PURE__*/_react["default"].createElement(_Box["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
1167
1189
  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.159",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,27 +5,59 @@ 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, showHideClassElements = [], fileName = "download"}) => {
9
+
10
+
11
+ const onHideElements = () => {
12
+
13
+ for (let index = 0; index < showHideClassElements.length; index++) {
14
+ const element = showHideClassElements[index];
15
+
16
+ let className = document.getElementsByClassName(element);
17
+ if (className != null)
18
+ {
19
+ className.style.display = "none";
20
+ }
21
+ }
22
+ }
23
+
24
+ const onShowElements = () => {
25
+
26
+ for (let index = 0; index < showHideClassElements.length; index++) {
27
+ const element = showHideClassElements[index];
28
+
29
+ let className = document.getElementsByClassName(element);
30
+ if (className != null)
31
+ {
32
+ className.style.display = "block";
33
+ }
34
+ }
35
+ }
36
+
9
37
 
10
38
  const printElement = () => {
11
39
 
40
+ onHideElements();
41
+
12
42
  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
- })
43
+ html2canvas(input, {backgroundColor: null, scale: scale})
44
+ .then((canvas) => {
45
+ const imgData = canvas.toDataURL("image/png", 1.0);
46
+ const pdf = new jsPDF();
47
+ const pdfWidth = pdf.internal.pageSize.getWidth();
48
+ const pdfHeight = pdf.internal.pageSize.getHeight();
49
+ const imgWidth = canvas.width;
50
+ const imgHeight = canvas.height;
51
+ const scaleFactor = Math.min(pdfWidth / imgWidth, pdfHeight / imgHeight);
52
+ const scaledWidth = imgWidth * scaleFactor;
53
+ const scaledHeight = imgHeight * scaleFactor;
54
+ const x = (pdfWidth - scaledWidth) / 2;
55
+ const y = 0; // Set y coordinate to 0 to align to the top
56
+ pdf.addImage(imgData, "PNG", x, y, scaledWidth, scaledHeight);
57
+ pdf.save(fileName + ".pdf");
58
+ });
59
+
60
+ onShowElements();
29
61
  }
30
62
 
31
63