zoukankan      html  css  js  c++  java
  • 小程序预览pdf文件

    有个业务需求,需要在小程序查看客户已开的发票

    发票地址:

    https://www.chinaeinv.com/p.jspa?cxxxxxxxxxxxx

    刚开始是想利用webview当作外链进行跳转访问的

    但是存在一个问题,该网页是在公众号内展示的,要预览就要先静默登录

    且不是该公众号的开发者,所以实现的可能性比较小

    不过,微信中有下载预览的api,可以直接拿过来用,从而实现预览

    对于我这样的懒汉来说,非常友好

    我的文件是固定的pdf格式,所以我是直接将fielType的值,设置为了'pdf'

    具体的用法见下方:




    downloadFile(url) { let _this = this wx.downloadFile({ url: url, success: function(res) { var filePath = res.tempFilePath; console.log(filePath); wx.openDocument({ filePath: filePath, fileType: 'pdf', success: function(res) { console.log(res); }, fail: function(res) { console.log(res); }, complete: function(res) { console.log(res); } }) }, fail: function(res) { console.log('文件下载失败'); }, complete: function(res) {}, }) }

      

    实现方法千千万,就看自己的选择,如果你觉得这种不适合你,还可以选别的鸭

     

     

  • 相关阅读:
    SQL Server Management Studio
    uiimage拉伸
    时间空间复杂度
    冒泡选择排序

    插入排序
    快速构建APP
    TTTAtibutedlabel
    Git命令
    适配
  • 原文地址:https://www.cnblogs.com/tongjiaojiao/p/11752983.html
Copyright © 2011-2022 走看看