-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The PDF file is NOT Created - Wrong filePath #261
Comments
Facing the same problem. Path is showing - /storage/emulated/0/Android/data/com.reactnative/files/Documents/test.pdf |
If you guys still have an issue concerning the file path and the pdf not getting created in the appropriate folder. Go directly to the source code in your node module
with
And that should change the file path to the appropriate location inside your emulator/device. |
@Allstern "react-native-html-pdf -> android ..." not exists. only "index.d.ts, license, package.json and readme". am I looking in the wrong folder? |
In your node module folder |
@Allstern |
Did you find a solution or another library to convert html to pdf ? (Using react native) |
Thanks alot it worked for me for others i would recommend you to use patch-package |
I am unable find file on ios - file path - "/var/mobile/Containers/Data/Application/..some id.../Documents/file.pdf" Can someone help here.... |
Can we customize the location of file ?? |
Yes you can. as i did changed with |
This will help https://www.youtube.com/watch?v=4CBUXv8d0I0 |
This crashes the application when a 'directory' key is passed after changing to this, I am on a Samsung device running on android 12 |
My app crashed when build apk with error: "fd cannot be null" |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
it worked thanks. |
What I'm going to suggest may meet this issue (I hope). I tried several ways and always had problems on Android while iOS worked perfectly. My approach was to split the responsibility into two different steps. Instead of being completely dependent on import { PermissionsAndroid, Platform } from 'react-native';
import RNHTMLtoPDF from 'react-native-html-to-pdf';
import {
DocumentDirectoryPath,
ExternalStorageDirectoryPath,
writeFile,
} from '@dr.pogodin/react-native-fs';
const IS_ANDROID = Platform.OS === 'android';
const BASE_PATH = IS_ANDROID ? `${ExternalStorageDirectoryPath}/Download` : DocumentDirectoryPath;
export async function savePDF(html: string, fileName: string): Promise<void> {
if (IS_ANDROID) {
const outcome = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE
);
if (outcome === PermissionsAndroid.RESULTS.DENIED) {
throw new Error('DENIED "WRITE_EXTERNAL_STORAGE" PERMISSION');
}
}
const result = await RNHTMLtoPDF.convert({ html, base64: true });
if (!result.base64) {
throw new Error('Failed to convert HTML to PDF');
}
await writeFile(`${BASE_PATH}/${fileName.toLowerCase()}.pdf`, result.base64, 'base64');
} |
how to set path in ios? |
@FranciscoMendes10866 I was thinking about this solution before and I fond that you are working on it , it's work for me with this logic , and it's logical because I need just to convert the html to pdf afer that I will read it and write it with react-native-fs library |
Recently,
RNHTMLtoPDF.convert()
stopped doing anything! No error is provided, and the file is not created. However, I noticed that thefilePath
, which it uses does NOT actually exist (to the best of my knowledge.) This occurs on Android. I have not, yet, tried it on iOS.build.grade:
My code:
Versions:
The text was updated successfully, but these errors were encountered: