philipphecht / react-native-doc-viewer

React Native Doc Viewer (Supports file formats: xls,ppt,doc,xlsx,pptx,csv,docx,png,jpg,pdf,xml,binary ...)
MIT License
91 stars 115 forks source link

could not open the pdf in Android #119

Open HelenChenVIP opened 6 years ago

HelenChenVIP commented 6 years ago

"react-native": "^0.50.0", "react-native-doc-viewer": "^2.7.8", Unable to open PDF, directly crash, unable to display error.But the url changes to an image's address, the fileType changes to a JPG, and the image is displayed

 handlePress = (item) => {
    this.setState({animating: true});
    if(Platform.OS === 'ios'){
      OpenFile.openDoc([{
        url:"http://172.16.12.65:4064/webgrid_api/AppConfig/2018年1-4月上饶市空气质量分析报告.pdf",
        fileNameOptional:item.ReportName
      }], (error, url) => {
         if (error) {
          this.setState({animating: false});
         } else {
          this.setState({animating: false});
           console.log(url)
         }
       })
    }else{
      //Android
      this.setState({ animating: true });
      OpenFile.openDoc([{
          url: "http://172.16.12.65:4064/webgrid_api/AppConfig/2018年1-4月上饶市空气质量分析报告.pdf", // Local "file://" + filepath
          fileName: "sample",
          cache: false,
          fileType: "pdf"
      }], (error, url) => {
          if (error) {
              this.setState({ animating: false });
              console.error(error);
          } else {
              this.setState({ animating: false });
              console.log(url)
          }
      })
    }
  }
waltChang1 commented 6 years ago

Maybe you need install an third app which can view your document in your device.

ly-lewis commented 6 years ago

我也碰到这个问题了! 请问您现在解决了吗?

waltChang1 commented 6 years ago

我也碰到这个问题了! 请问您现在解决了吗?

你需要咋你的设备上安装能打开文件的app,如 wps , Document viewer

ly-lewis commented 6 years ago

也就是说 我现在在模拟器上是看不了的 谢谢啦 我现在试试

在 2018年9月17日,09:08,waltChang1 notifications@github.com 写道:

我也碰到这个问题了! 请问您现在解决了吗?

你需要咋你的设备上安装能打开文件的app,如 wps , Document viewer

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/philipphecht/react-native-doc-viewer/issues/119#issuecomment-421865100, or mute the thread https://github.com/notifications/unsubscribe-auth/Abb_EvychK_HxCZDfL9IdWxrZLGpVnw3ks5ubvYIgaJpZM4WYLHC.

k3j123 commented 6 years ago

How do you make it so the file opens in the 3rd party app? Ive installed WPS but when I try to open the file it crashes my app.

HelenChenVIP commented 5 years ago

@waltChang1 in my phone i have wps ,word ,and so on... But i can not open the pdf, its crash

HelenChenVIP commented 5 years ago

@ly-lewis @waltChang1 anybody can help me ?thanks