通过addTextObject()接口添加示例文字

通过addTextObject()接口添加示例文字

HarmonyOS
2024-08-07 09:43:13
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
沉默如海
Button("添加示例文字")
          .fontSize(12)
          .onClick(async () => {
            let page: pdfService.PdfPage = this.document.getPage(this.pageIndex);
            let textStyle: pdfService.TextStyle = new pdfService.TextStyle;
            let fontList: Array<string> = font.getSystemFontList();
            if (fontList.length == 0) {
              this.showDialog('系统无可用字体','请尝试更新版本或设备');
              return;
            }
            let fontInfo: font.FontInfo = font.getFontByName(fontList[0]); //获取系统默认字体
            textStyle.fontInfo = { fontPath: fontInfo.path };
            textStyle.textSize = 20;
            page.addTextObject("hello world", 0, 0, textStyle); //添加示例文字
            this._pixelMap = page.getPagePixelMap();
          }).margin({ left: 15 })
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
分享
微博
QQ
微信
回复
2024-08-07 12:07:31


相关问题
Image 上怎么添加文字?
3599浏览 • 1回复 待解决
多行文字后面添加标签
561浏览 • 1回复 待解决
文字能否添加过渡色(不是背景)?
551浏览 • 1回复 待解决
如何给文字添加下划线?
1052浏览 • 1回复 待解决
通过getPage()接口翻页
610浏览 • 1回复 待解决
通过saveDocument()接口保存文件
753浏览 • 1回复 待解决
listContainer怎么通过addComponent添加布局
8391浏览 • 1回复 待解决
通过loadDocument()接口加载PDF文件
821浏览 • 1回复 待解决
应用通过什么接口获取设备标识信息
2023浏览 • 1回复 待解决
ArkTS层通过接口访问C++层对象
886浏览 • 1回复 待解决