Read PDF with Expo (ios & android)

One of the dependencies (react-native-webview) requires me to eject from Expo to link the dependencies properly. Do you guys know some work around for this without having to eject?

As you can see I still need to this:

Thank you so much. I try 3 lib until see that. It works very well with expo.

1 Like

There must be capability to pinch to zoom…

Hi @mufaddalhamidofficia,
Yes, you can use pinch to zoom just by passing withPinchZoom prop.
I hope that helps.

@xcarpentier thnx actually I was using an old version(0.7.2) instead of (3.x) therefore it was not working

@xcarpentier I am using your lib, I have problems when viewing the pdf, only by console can I see this message “DIRECT_BASE64”

some PDF files print as RAW code. same issue in github - closed.

It should be fixed in last version.

1 Like

thanks for answer, actualy i found the problem:

if we pass to FileSystem.createDownloadResumable filename for save with no .pdf ending(f.e. .pdf?param=foo) - this making display in RAW. my bad

Hi
On npmjs.com I see the following image:

Is it really deprecated? It was just updated (literally 20 mins ago). How can it be deprecated? I’m still using this lib and it works well, but just want to know if I need to switch or look for something else in the future.

Thanks

Sorry my bad.
You can still use it.
But the new version is now v4.0.0.

1 Like

I’ve been using this library and so far it works great as long as you use an url. I’ve been trying to open a pdf with base64 and on both android and ios it crashes.

From what I can tell from the error, it does detect the base64 thanks to the debug message, but then it throws 2 warnings and then react native throws a maximum update detph exceeded error.

Warning: Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.
* [native code]:null in __expoConsoleLog
- node_modules/react-native/Libraries/LogBox/LogBox.js:33:4 in console.error
- node_modules/expo/build/environment/muteWarnings.fx.js:27:4 in error
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:608:6 in warningWithoutStack
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:22076:31 in warnAboutInvalidUpdatesOnClassComponentsInDEV
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19809:47 in scheduleUpdateOnFiber
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:7861:16 in classComponentUpdater.enqueueSetState
- node_modules/react/cjs/react.development.js:325:2 in Component.prototype.setState
* src/screens/Shared/DocuwareListScreen/index.js:47:14 in DocuwareListScreen#showPDF
* src/screens/Shared/DocuwareListScreen/documentItem.js:22:12 in DocumentItem
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:10989:26 in renderWithHooks
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:13385:34 in updateFunctionComponent
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:22002:24 in beginWork$$1
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20871:23 in performUnitOfWork
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20848:38 in workLoopSync
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20456:22 in performSyncWorkOnRoot
* [native code]:null in performSyncWorkOnRoot
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5703:31 in runWithPriority$argument_1
- node_modules/react-native/node_modules/scheduler/cjs/scheduler.development.js:818:23 in unstable_runWithPriority
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5698:21 in flushSyncCallbackQueueImpl
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5686:28 in flushSyncCallbackQueue
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19845:30 in scheduleUpdateOnFiber
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:11880:16 in dispatchAction
* [native code]:null in dispatchAction
- node_modules/promise/setimmediate/core.js:37:13 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:24 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:135:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:183:16 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:446:30 in callImmediates
* [native code]:null in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:396:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:144:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:373:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:143:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue

Im on Expo SDK38, is there anything I can do to solve this or is this due to an incompatibility beause of the version of expo Im using?

It was a logical error from my part. Im using useLazyQuery to retrieve the base64 string from graphql, I was under the assumption it only executed once, instead I completely forgot that it works the same as a hook so the data is there always, and as such it kept executing the function I had defined for opening the pdfs.

Still took me quite a while to notice, tried to even make some kind of workaround using filesystem or images trying to see if there was a way to decode it or something. Im glad I noticed.

Hello! I’m facing an issue with blank pdf on iOS. On Android works fine.
Output android: URL_TO_BASE64
FilePath: file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252FDentamarketAdmin-1d201ec7-24e5-44e6-ba76-14734df18548/1603885606637.pdf

Output iOS: DIRECT_URL
FilePath: file:///var/mobile/Containers/Data/Application/75AC183E-1870-4895-BB5D-5610C4AA6714/Library/Caches/ExponentExperienceData/%2540anonymous%252FDentamarketAdmin-1d201ec7-24e5-44e6-ba76-14734df18548/1603885672863.pdf

Additional info:

  • expo-file-system to downloadAsync
  • expo: 38.0.8
  • rn-pdf-reader-js: 4.1.1

Anyone else has the same problem ?

Works fine Thanks !!!

Hi xcarpentier we have been using your library, but all of a sudden, in Android mobiles it has started to not show de pdf document, it only appears a blank screen, attached evidence, will you think is a situation based on any Android update or can we consider any issue in the library ? we are using version 4.1.1 … best regards and thank you in advance for your comments:

Ola xcarpentier, comecei a usar sua biblioteca, mas logo na primeira tentativa aparece que o arquivo foi carregado ‘URL_TO_BASE64’, mas na tela nao é mostrado nada alem de uma mensagem “Invalid PDF structure”. Tentei com diversos PDF e nenhum funcionou. Voce poderia me ajudar por favor?
Eu salvo o PDF com FileSystem e quando coloco ele na uri aparece isso.
Por favor me ajude
Estou usando no android

please, help me

Hello Pedro, did you manage to solve your mistake?

Hi,

I have a problem with the library. It works extremely well in development mode with Expo. Unfortunately, when I built the apk image and used it, it doesn’t work. Whenever I go to the PDF Reader component the app is reloaded.

This is the error message;

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
at Tl([native code])
at value([native code])