Small program more needs to download, preview PDF file

Source: Internet
Author: User
Tags file size
Wx.downloadfile and wx.opendocument combination of small programs (ii)

Should be in the middle also to take over other projects, so the interval is a little awkward, then the last time, continue to pits.
This demand began to be a special issue, with a large background + sliding switch selection, select the slide to switch the small picture, background background to display a picture of the corresponding special issue. Look directly at the picture:

have been done. And then the product asks if you can directly use the PDF online preview (wry smile ...) ), it was a rip-off, because it didn't work, and the applet document didn't finish. Then honestly continue to brush the document.
Kung Fu is not a conscientious person, found a good thing: wx.opendocument

Code:

Wx.downloadfile ({
      URL: ' https://*****.***.work/videos/test2.pdf ',
      success:function (res) {
        Console.log (res)
        var Path = Res.tempfilepath              //Returns the file temporary address used to open the local preview using the
        wx.opendocument ({
          FilePath: Path,
          success:function (res) {
            console.log (' Open Document Success ')}}
        )
      },
      fail:function (res) {
        Console.log (res)
      }
    })

Started to drop directly on the server is the client side to provide a PDF, file size 31MB, have thought will be very large, user download will be very long, sure enough, the direct fail callback back to me:
exceeded the maximum size of the file, came back and looked up, Local storage File size limit: 10MB; So I changed to a smaller PDF, I returned the address successfully, and a PDF preview was implemented on the phone. But this size limit, I can not solve, only limit the size of the PDF file, if you want to long-term save to the local, you need to use the wx.savefile. Pits Road to be continued

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.