# wx.openDocument(Object object)

with Promise style call: Supported

Mini Program plugin: Support, need to Mini Program base library version no less than 2.15.0

A new page opens the document. WeChat Client 7.0.12 Version of the default display of the upper right corner menu on, after the default version does not show, you need to take the initiative to pass showMenu

# parameter

# Object object

attribute type Default values Required Introductions Minimum version
filePath string yes File path (Local path) , through downloadFile Get
showMenu boolean false no Whether to show the top right menu 2.11.0
fileType string no File type, specify file type to open the file 1.4.0
success function no Interface calls the successful callback function
fail function no Interface calls failed callback functions
complete function no Callback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.fileType Legal value

value Introductions Minimum version
doc doc format
docx docx format
xls xls format
xlsx xlsx format
ppt ppt format
pptx pptx format
pdf pdf format

# sample code


wx.downloadFile({
  // Example Url, not real
  url: 'http://example.with/somefile.pdf',
  success: function (res) {
    const filePath = res.tempFilePath
    wx.openDocument({
      filePath: filePath,
      success: function (res) {
        console.log("Document opened successfully.")
      }
    })
  }
})