Cannot display pdf (file is of invalid format)
kosbog opened this issue · 3 comments
kosbog commented
Have the Cannot display pdf (*file_name* is of invalid format)
error on android. On iOS everything is fine. Also, I did an extra step for android api 30+.
Maybe its a wrong file path, i have this: /data/user/0/com.pmgmobileapp/cache/*file_name*.pdf
.
Versions:
"react-native-file-viewer": "^2.1.5",
"react-native": "0.66.4",
Android:
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
Code:
const options1: FetchInit = {
method: 'GET',
path: `${CACHED_PATH}/${file.name}`
};
const response = await FileSystem.fetch(`${CORE_URL}${url}`, options);
if (response) {
const fileUri = `${Dirs.CacheDir}/${file.name}`;
const fileStat = await FileSystem.stat(fileUri);
await FileViewer.open(`${Dirs.CacheDir}/${file.name}`);
}
kosbog commented
Already found a source of the problem and it is not related to this viewer.