可以使用web组件实现pdf文件预览。word文档不支持预览,建议转换成pdf文件后进行预览。相关demo如下,建议在真机上查看预览效果:import web_webview from '@ohos.web.webview'; @Entry @Component struct Index { webviewController: web_webview.WebviewController = new web_webview.WebviewController(); build() { Column({space:10}) { //预览在线的pdf文件资源 Web({ src:'https:xxx', controller: this.webviewController}).domStorageAccess(true) //预览本地的pdf文件资源 // Web({ src:$rawfile('git.pdf'), controller: this.webviewController}).domStorageAccess(true) }.width('100%').height('100%').justifyContent(FlexAlign.Center).borderWidth(1) } }
可以使用web组件实现pdf文件预览。word文档不支持预览,建议转换成pdf文件后进行预览。
相关demo如下,建议在真机上查看预览效果: