HTML to PDF always blank screen in iOS - React Native

107 Views Asked by At

I am using react-native-html-to-pdf package to convert html content to pdf, this is working fine on android but iOS it always return a blank white screen.

    const options = {
      html: htmlContent,
      fileName:
        voucher.clientID.toString() + ' - ' + voucher.archiveNo.toString(),
      directory: 'Documents',
    };

    const pdfFile: any = await RNHTMLtoPDF.convert(options);

Anyone has a solution for this issue?

1

There are 1 best solutions below

0
Pratik Prakash Bindage On

Check whether your iOS app has the required rights to write to the supplied directory ('Documents'). To perform file operations on iOS, you may need to use the RNFS (React Native File System) package. Make that your programme has permission to write to the Documents directory.

import RNFS from 'react-native-fs';

const path = RNFS.DocumentDirectoryPath + '/' + options.fileName + '.pdf';
const pdfFile = await RNHTMLtoPDF.convert({ ...options, filePath: path });