react-base64-to-pdf
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -6,7 +6,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = __importDefault(require("react")); | ||
var PDFDownloadButton = function (_a) { | ||
var base64 = _a.base64, _b = _a.downloadFileName, downloadFileName = _b === void 0 ? "file.pdf" : _b, style = _a.style, className = _a.className; | ||
return (react_1.default.createElement("a", { href: "data:application/octet-stream;base64,".concat(base64), download: downloadFileName, style: style, className: className }, "Download PDF")); | ||
const react_1 = __importDefault(require("react")); | ||
const PDFDownloadButton = ({ base64, downloadFileName = "file.pdf", style, className, }) => { | ||
return (react_1.default.createElement("a", { href: `data:application/octet-stream;base64,${base64}`, download: downloadFileName, style: style, className: className }, "Download PDF")); | ||
}; | ||
exports.default = PDFDownloadButton; |
@@ -26,14 +26,13 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = __importStar(require("react")); | ||
var PDFInfo = function (_a) { | ||
var base64 = _a.base64; | ||
var _b = (0, react_1.useState)(null), fileSize = _b[0], setFileSize = _b[1]; | ||
var _c = (0, react_1.useState)(""), pdfVersion = _c[0], setPdfVersion = _c[1]; | ||
var _d = (0, react_1.useState)(""), createDate = _d[0], setCreateDate = _d[1]; | ||
var _e = (0, react_1.useState)(""), modifyDate = _e[0], setModifyDate = _e[1]; | ||
var _f = (0, react_1.useState)(""), creatorTool = _f[0], setCreatorTool = _f[1]; | ||
(0, react_1.useEffect)(function () { | ||
const react_1 = __importStar(require("react")); | ||
const PDFInfo = ({ base64 }) => { | ||
const [fileSize, setFileSize] = (0, react_1.useState)(null); | ||
const [pdfVersion, setPdfVersion] = (0, react_1.useState)(""); | ||
const [createDate, setCreateDate] = (0, react_1.useState)(""); | ||
const [modifyDate, setModifyDate] = (0, react_1.useState)(""); | ||
const [creatorTool, setCreatorTool] = (0, react_1.useState)(""); | ||
(0, react_1.useEffect)(() => { | ||
var _a, _b, _c, _d; | ||
if (base64) { | ||
var bin = atob(base64); | ||
const bin = atob(base64); | ||
setFileSize(Math.round(bin.length / 1024)); | ||
@@ -40,0 +39,0 @@ setPdfVersion(((_a = bin.match(/^.PDF-([0-9.]+)/)) === null || _a === void 0 ? void 0 : _a[1]) || "Unknown"); |
@@ -6,7 +6,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var react_1 = __importDefault(require("react")); | ||
var PDFPreview = function (_a) { | ||
var base64 = _a.base64, _b = _a.width, width = _b === void 0 ? "100%" : _b, _c = _a.height, height = _c === void 0 ? "842pt" : _c; | ||
return (react_1.default.createElement("object", { style: { width: width, height: height }, type: "application/pdf", data: "data:application/pdf;base64,".concat(base64) }, "PDF cannot be displayed.")); | ||
const react_1 = __importDefault(require("react")); | ||
const PDFPreview = ({ base64, width = "100%", height = "842pt", }) => { | ||
return (react_1.default.createElement("object", { style: { width, height }, type: "application/pdf", data: `data:application/pdf;base64,${base64}` }, "PDF cannot be displayed.")); | ||
}; | ||
exports.default = PDFPreview; |
{ | ||
"name": "react-base64-to-pdf", | ||
"version": "1.1.4", | ||
"description": "A React component to display and download PDF files from Base64 strings.", | ||
"version": "1.1.5", | ||
"description": "A React library for rendering Base64-encoded PDF files and providing download options.", | ||
"main": "dist/index.js", | ||
@@ -31,7 +31,7 @@ "types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@types/node": "^22.7.6", | ||
"@types/react": "^18.3.11", | ||
"@types/react-dom": "^18.3.1", | ||
"@types/node": "^22.7.6", | ||
"typescript": "^5.6.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9028
94