Gathering detailed insights and metrics for @react-native-oh-tpl/react-native-doc-viewer
Gathering detailed insights and metrics for @react-native-oh-tpl/react-native-doc-viewer
Gathering detailed insights and metrics for @react-native-oh-tpl/react-native-doc-viewer
Gathering detailed insights and metrics for @react-native-oh-tpl/react-native-doc-viewer
React Native Doc Viewer (Supports file formats: xls,ppt,doc,xlsx,pptx,csv,docx,png,jpg,pdf,xml,binary ...)
npm install @react-native-oh-tpl/react-native-doc-viewer
Typescript
Module System
Node Version
NPM Version
Java (40.64%)
Objective-C (39.91%)
C# (11.92%)
Python (3.28%)
JavaScript (2.95%)
Ruby (1.3%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
96 Stars
234 Commits
115 Forks
5 Watchers
16 Branches
20 Contributors
Updated on May 23, 2025
Latest Version
2.7.8-0.0.2
Package Id
@react-native-oh-tpl/react-native-doc-viewer@2.7.8-0.0.2
Unpacked Size
39.47 kB
Size
17.38 kB
File Count
38
NPM Version
10.2.4
Node Version
20.11.0
Published on
Nov 07, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
2
A React Native bridge module: Document Viewer for files (pdf, png, jpg, xls, doc, ppt, xlsx, docx, pptx etc.)
Changelog:
2.7.8 - XLS Example Local File IOS 97-2003
2.7.7 - "react": "^16.3.0-alpha.1","react-native": "0.54.3"
2.7.5 - Pull Request local file from LeMinh1995 + Pull Request podspec Form Linh1987
2.7.3 - Example Local File
2.7.2 - Progress Download Feedback in example and Done Button Callback IOS
2.7.1 - Fix Progress IOS Download
2.6.9 - Progress IOS DOWNLOAD Document Callback in Native Code
2.6.0 - Android Openbase64
2.5.2 - OpenDocAndroid
2.5.1 - Cleanings
2.5.0 - Update Project for React Native 0.50.3
$ npm install react-native-doc-viewer --save
$ react-native link react-native-doc-viewer
If your project uses CocoaPods to manage React installation (especially with Expo-detached project), most likely you will run into issue with header files not found as described here (https://docs.expo.io/versions/latest/guides/expokit.html#changing-native-dependencies "Changing Native Dependencies"). It will be helpful to follow these steps to have it compiled successfully:
npm install react-native-doc-viewer --save
Add the plugin dependency to your Podfile, pointing at the path where NPM installed it:
pod 'RNReactNativeDocViewer', path: '../node_modules/react-native-doc-viewer'
pod install
In XCode, in the project navigator, right click Libraries
➜ Add Files to [your project's name]
Go to node_modules
➜ react-native-doc-viewer
and add RNDocViewer.xcodeproj
In XCode, in the project navigator, select your project. Add libRNDocViewer.a
to your project's Build Phases
➜ Link Binary With Libraries
Linked Frameworks and Libraries must have this 2 Libraries (AssetsLibrary.framework & QuickLook.framework). When not you have to add them.
When you Show http Links don't forget to set APP Transport Security Settings -> Allow Arbitrary Loads to YES
Cmd+R
)<android/app/src/main/java/[...]/MainApplication.java
import com.philipphecht.RNDocViewerPackage;
to the imports at the top of the filenew RNDocViewerPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-doc-viewer'
project(':react-native-doc-viewer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-doc-viewer/android')
android/app/build.gradle
:
compile project(':react-native-doc-viewer')
RNReactNativeDocViewer.sln
in node_modules/react-native-react-native-doc-viewer/windows/RNReactNativeDocViewer.sln
folder to their solution, reference from their app.MainPage.cs
appusing com.Philipphecht.RNReactNativeDocViewer;
to the usings at the top of the filenew RNReactNativeDocViewerPackage()
to the List<IReactPackage>
returned by the Packages
methodresource | description |
---|---|
DoneButtonEvent | return true |
RNDownloaderProgress | return Progress Float |
resource | description |
---|---|
openDoc | {url:String,fileNameOptional:String (optional)} |
openDocb64 | {url:String,fileName:String,fileType:String } |
openDocBinaryinUrl | {url:String,fileName:String,fileType:String } |
resource | description |
---|---|
openDoc | {url:String,fileName:String, cache:boolean} |
openDocb64 | {url:String,fileName:String,fileType:String, cache:boolean } |
openDocBinaryinUrl | not implemented yet |
1import React, { Component } from 'react'; 2import { 3 AppRegistry, 4 StyleSheet, 5 Text, 6 View, 7 Platform, 8 Button, 9 Alert, 10 ActivityIndicator, 11 NativeAppEventEmitter, 12 DeviceEventEmitter, 13 NativeModules, 14 NativeEventEmitter, 15 TouchableHighlight 16} from 'react-native'; 17import OpenFile from 'react-native-doc-viewer'; 18var RNFS = require('react-native-fs'); 19var SavePath = Platform.OS === 'ios' ? RNFS.MainBundlePath : RNFS.DocumentDirectoryPath; 20export default class DocumentViewerExample extends Component { 21 constructor(props) { 22 super(props); 23 this.state = { 24 animating: false, 25 progress: "", 26 donebuttonclicked: false, 27 } 28 this.eventEmitter = new NativeEventEmitter(NativeModules.RNReactNativeDocViewer); 29 this.eventEmitter.addListener('DoneButtonEvent', (data) => { 30 /* 31 *Done Button Clicked 32 * return true 33 */ 34 console.log(data.close); 35 this.setState({donebuttonclicked: data.close}); 36 }) 37 this.didPressToObjcButton = this.didPressToObjcButton.bind(this); 38 } 39 40 componentDidMount(){ 41 // download progress 42 this.eventEmitter.addListener( 43 'RNDownloaderProgress', 44 (Event) => { 45 console.log("Progress - Download "+Event.progress + " %") 46 this.setState({progress: Event.progress + " %"}); 47 } 48 49 ); 50 } 51 52 componentWillUnmount (){ 53 this.eventEmitter.removeListener(); 54 } 55 /* 56 * Handle WWW File Method 57 * fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url the File Extension is missing. 58 */ 59 handlePress = () => { 60 this.setState({animating: true}); 61 if(Platform.OS === 'ios'){ 62 OpenFile.openDoc([{ 63 url:"https://calibre-ebook.com/downloads/demos/demo.docx", 64 fileNameOptional:"test filename" 65 }], (error, url) => { 66 if (error) { 67 this.setState({animating: false}); 68 } else { 69 this.setState({animating: false}); 70 console.log(url) 71 } 72 }) 73 }else{ 74 //Android 75 this.setState({animating: true}); 76 OpenFile.openDoc([{ 77 url:"https://www.huf-haus.com/fileadmin/Bilder/Header/ART_3/Header_HUF_Haus_ART_3___1_.jpg", // Local "file://" + filepath 78 fileName:"sample", 79 cache:false, 80 fileType:"jpg" 81 }], (error, url) => { 82 if (error) { 83 this.setState({animating: false}); 84 console.error(error); 85 } else { 86 this.setState({animating: false}); 87 console.log(url) 88 } 89 }) 90 } 91 92 } 93 94 95 /* 96 * Handle Local File Method 97 * fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url the File Extension is missing. 98 */ 99 handlePressLocal = () => { 100 this.setState({animating: true}); 101 if(Platform.OS === 'ios'){ 102 OpenFile.openDoc([{url:SavePath+"/react-native-logo.jpg", 103 fileNameOptional:"test filename" 104 }], (error, url) => { 105 if (error) { 106 this.setState({animating: false}); 107 } else { 108 this.setState({animating: false}); 109 console.log(url) 110 } 111 }) 112 }else{ 113 OpenFile.openDoc([{url:SavePath+"/demo.jpg", 114 fileName:"sample", 115 cache:false, 116 fileType:"jpg" 117 }], (error, url) => { 118 if (error) { 119 this.setState({animating: false}); 120 } else { 121 this.setState({animating: false}); 122 console.log(url) 123 } 124 }) 125 126 } 127 } 128 129 handlePressLocalXLS = () => { 130 this.setState({animating: true}); 131 if(Platform.OS === 'ios'){ 132 OpenFile.openDoc([{url:SavePath+"/SampleXLSFile_19kb.xls", 133 fileNameOptional:"Sample XLS 94-2003" 134 }], (error, url) => { 135 if (error) { 136 this.setState({animating: false}); 137 } else { 138 this.setState({animating: false}); 139 console.log(url) 140 } 141 }) 142 }else{ 143 OpenFile.openDoc([{url:SavePath+"/demo.jpg", 144 fileName:"sample", 145 cache:false, 146 fileType:"jpg" 147 }], (error, url) => { 148 if (error) { 149 this.setState({animating: false}); 150 } else { 151 this.setState({animating: false}); 152 console.log(url) 153 } 154 }) 155 156 } 157 } 158 159 160 /* 161 * Binary in URL 162 * Binary String in Url 163 * fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url you dont have an File Extensions 164 */ 165 handlePressBinaryinUrl = () => { 166 this.setState({animating: true}); 167 if(Platform.OS === 'ios'){ 168 OpenFile.openDocBinaryinUrl([{ 169 url:"https://storage.googleapis.com/need-sure/example", 170 fileName:"sample", 171 fileType:"xml" 172 }], (error, url) => { 173 if (error) { 174 console.error(error); 175 this.setState({animating: false}); 176 } else { 177 console.log(url) 178 this.setState({animating: false}); 179 } 180 }) 181 }else{ 182 OpenFile.openDocBinaryinUrl([{ 183 url:"https://storage.googleapis.com/need-sure/example", 184 fileName:"sample", 185 fileType:"xml", 186 cache:true 187 }], (error, url) => { 188 if (error) { 189 console.error(error); 190 this.setState({animating: false}); 191 } else { 192 console.log(url) 193 this.setState({animating: false}); 194 } 195 }) 196 } 197 } 198 199 /* 200 * Base64String 201 * put only the base64 String without data:application/octet-stream;base64 202 * fileType Default == "" you can use it, to set the File Extension (pdf,doc,xls,ppt etc) when in the Url you dont have an File Extensions 203 */ 204 handlePressb64 = () => { 205 if(Platform.OS === 'ios'){ 206 OpenFile.openDocb64([{ 207 base64:"{BASE64String}" 208 fileName:"sample", 209 fileType:"png" 210 }], (error, url) => { 211 if (error) { 212 console.error(error); 213 } else { 214 console.log(url) 215 } 216 }) 217 }else{ 218 //Android 219 OpenFile.openDocb64([{ 220 base64:"{BASE64String}" 221 fileName:"sample", 222 fileType:"png", 223 cache:true /*Use Cache Folder Android*/ 224 }], (error, url) => { 225 if (error) { 226 console.error(error); 227 } else { 228 console.log(url) 229 } 230 }) 231 } 232 233 /* 234 * Video File 235 */ 236 handlePressVideo = () => { 237 if(Platform.OS === 'ios'){ 238 OpenFile.playMovie(video, (error, url) => { 239 if (error) { 240 console.error(error); 241 } else { 242 console.log(url) 243 } 244 }) 245 }else{ 246 Alert.alert("Android coming soon"); 247 } 248 } 249 250 251 <Button 252 onPress={this.handlePress.bind(this)} 253 title="Press Me Open Doc Url" 254 accessibilityLabel="See a Document" 255 /> 256 <Button 257 onPress={this.handlePressBinaryinUrl.bind(this)} 258 title="Press Me Open BinaryinUrl" 259 accessibilityLabel="See a Document" 260 /> 261 <Button 262 onPress={this.handlePressLocal.bind(this)} 263 title="Press Me Open Doc Path" 264 accessibilityLabel="See a Document" 265 /> 266 <Button 267 onPress={this.handlePressLocalXLS.bind(this)} 268 title="Press Me Open XLS DOC Path" 269 accessibilityLabel="See a Document" 270 /> 271 <Button 272 onPress={this.handlePressb64.bind(this)} 273 title="Press Me Open Base64 String" 274 accessibilityLabel="See a Document" 275 /> 276 <Button 277 onPress={()=>this.handlePressVideo("http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4")} 278 title="Press Me Open Video" 279 accessibilityLabel="See a Document" 280 /> 281}
Copyright (c) 2017-present, Philipp Hecht philipp.hecht@icloud.com
If this project help you reduce time to develop, you can give me a cup of coffee :)
Etherum wallet: 0x124F99647a904240945d8B582eEf1E3CD6D00a8a
No vulnerabilities found.
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 7/13 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
88 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More