UNPKG

react-native-pdf-from-image

Version:
39 lines (35 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createPdf = createPdf; var _reactNative = require("react-native"); var _contants = require("./contants.js"); // @ts-ignore We want to check whether __turboModuleProxy exitst, it may not const isTurboModuleEnabled = global.__turboModuleProxy != null; const pdffromimage = isTurboModuleEnabled ? require('./NativePdfFromImage').default : _reactNative.NativeModules.PdfFromImage; function createPdf(params) { // Sanitize document name by removing file extension const sanitizedName = params.name.replace(/\.[^/.]+$/, ''); // Sanitize image paths for iOS const sanitizedImagePaths = params.imagePaths.map(path => { if (path.startsWith('file://')) { return path.replace('file://', ''); } return path; }); // Determine the paper size let paperSize = params.customPaperSize; if (!paperSize && params.paperSize) { paperSize = _contants.paperSizes[params.paperSize]; } // Create a new ImageObject with sanitized paths const sanitizedParams = { ...params, imagePaths: sanitizedImagePaths, paperSize, name: sanitizedName }; return pdffromimage.createPdf(sanitizedParams); } //# sourceMappingURL=index.js.map