HarmonyOS 如何预览.word/.exe/.ppt/.pdf文件

目前使用filepreview可以预览.txt文件,但是在预览.pdf文件时,无法正确预览

HarmonyOS
2024-12-23 16:00:04
651浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

Preview Kit目前并不支持预览pdf,支持文件格式详情可参考api:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/preview-arkts-V5#section1081123302517

目前pdf有推荐方案,可以通过webview 组件加载pdf格式的文件。

具体代码如下:

import { webview } from '@kit.ArkWeb'

@Entry
@Component
struct WebViewPage {
  private webviewController: WebviewController = new webview.WebviewController();

  aboutToAppear() {
    // 配置Web开启调试模式
    webview.WebviewController.setWebDebuggingAccess(true);
  }
  aboutToRecycle(): void {
  }
  build() {
    Row() {
      Column() {
        // Text('测试pdf')
        Web({
          src: 'https://www.huawei.com/xxx.pdf#toolbar=0&navpanes=0',

          controller: this.webviewController
        })
          .height('100%')
          .width('100%')
          .javaScriptAccess(true)
          .multiWindowAccess(false)
          .domStorageAccess(true)
          .allowWindowOpenMethod(true)
          .zoomAccess(false)
          .domStorageAccess(true)
      }
      .width('100%')
    }
    .height('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
分享
微博
QQ
微信
回复
2024-12-23 19:32:38


相关问题
HarmonyOS 是否支持pdfWord文件预览
1279浏览 • 1回复 待解决
HarmonyOS 关于预览PDFword等类型文件
1101浏览 • 1回复 待解决
鸿蒙支持在线pdf,word这些预览功能么
12959浏览 • 3回复 待解决
HarmonyOS PDF文件预览
846浏览 • 1回复 待解决
HarmonyOS 使用PDF kit预览PDF文件
860浏览 • 1回复 待解决
如何实现pdf文件预览
1324浏览 • 1回复 待解决
HarmonyOS web组件预览PDF文件问题
949浏览 • 1回复 待解决
HarmonyOS 如何使用API预览word文档
891浏览 • 1回复 待解决
PDF预览如何隐藏PDF操作按钮
2255浏览 • 1回复 待解决