Viewing .doc files in React Native with uri

PDFTron - React Native - Android

PDFTron for React Native (Android) unable to render files other than PDF with content Uri.

I am trying to render documents (.pdf, .doc, .docx etc.) using content uri with PDFTron with React Native (Android). In the documentation it is mentioned to pass uri in path (document={path}).

I am able to render .pdf files although other file types (such as .doc or .docx) are unable to render.

Does PDFTron for React Native support document rendering (*for file types other than PDF) with content uri?

Or I have to include file extension? If so, which API do I use?

Here is the Snapshot of the log and the output while trying to render .docx file

Any suggestion appreciated.
Thanks

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi there, the issue is your content URI is not proper content URI scheme, they typically look like the follows:

“content://com.google.android.apps.docs.storage/document/acc%3D1%3Bdoc%3Dencoded%3D3ANW16SOSAt4EvkKHsYo_159-fKCSyFbzE4zHcCNeew3N7oDXd0jgvbNFDM%3D”

Essentially, the URI needs to pass the check where its scheme is equal to ContentResolver.SCHEME_CONTENT

From the screenshot, your URI is not really a content URI, could you please make sure to use proper content URI?

Thanks.

Hi Shirley, sorry for the late response. But I am able to render pdf files using the same approach.
Here’s snapshots of pdf I am able to render using similar uri.
image

Do you suggest any work around to render .docx files?

Thanks

Hi, as described in my previous message, you will need to box your link to a proper content uri with the “SCHEME_CONTENT” scheme. There is no other way. This is a proper solution, not a workaround. Alternatively, you can make a copy to the app’s sandbox, and send the local link (file://xxx.docx) to the viewer. Thanks.