I have implement method to download pdf fro both ios and android but I'm unable to access the iOS file saved location.My implementation as follow,
const downloadAndSavePDFs = async () => {
setDownloadingToDevice(true);
const externalStorageDirectory =
Platform.OS === 'android'
? RNFS.DownloadDirectoryPath
: RNFS.DocumentDirectoryPath;
const imageArray = downloadImages.map((item: any) => item.image);
const pdfContent = imageArray
.map((base64Image: any) => `<img src=${base64Image} />`)
.join('');
const imageStyles = `
img {
width: 100%;
height: 90vh;
object-fit: contain;
page-break-inside: avoid;
}
`;
const htmlContent = `
<!doctype html>
<html>
<body>
<div class="pdf-content">
${pdfContent}
</div>
</body>
</html>
`;
const options = {
html: htmlContent,
fileName:
voucher.clientID.toString() + ' - ' + voucher.archiveNo.toString(),
directory: 'Documents',
};
const pdfFile: any = await RNHTMLtoPDF.convert(options);
const downloadsPath = `${externalStorageDirectory}/${
voucher.clientID + ' - ' + voucher.archiveNo
}.pdf`;
try {
if (Platform.OS === 'android') {
await RNFS.moveFile(pdfFile.filePath, downloadsPath);
} else if (Platform.OS === 'ios') {
const shareOptions = {
title: 'Share PDF',
message: 'Check out this PDF!',
url: pdfFile.filePath,
type: 'application/pdf',
};
await Share.open(shareOptions);
}
setDownloadingToDevice(false);
} catch (error) {
console.log(error);
setDownloadingToDevice(false);
}
};
I want share saved pdf file in ios, Share option is working but shared file is always empty white screen. I tired to convert HTML content as base64 string but it also not working
Please help me to sort out this issue