跳到主要内容

GetTextPr

返回当前表单的文本属性。

备注

仅在此类型表单支持时使用。

继承自 ApiFormBase.GetTextPr。

语法​

expression.GetTextPr();

expression - 表示 ApiPictureForm 类的变量。

参数​

此方法没有任何参数。

返回值​

ApiTextPr

示例​

获取文档中图片表单的文本格式设置。

// How do I access the text style applied to a picture form in a document?

// Read and then adjust the typography of a picture form in a document.

let doc = Api.GetDocument();
let pictureForm = Api.CreatePictureForm({"key": "Personal information", "tip": "Upload your photo", "required": true, "placeholder": "Photo", "scaleFlag": "tooBig", "lockAspectRatio": true, "respectBorders": false, "shiftX": 50, "shiftY": 50});
let paragraph = doc.GetElement(0);
paragraph.AddElement(pictureForm);
pictureForm.SetImage("https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png", Api.MillimetersToEmus(70), Api.MillimetersToEmus(80));
let textPr = Api.CreateTextPr();
textPr.SetFontSize(30);
textPr.SetBold(true);
pictureForm.SetTextPr(textPr);
let formTextPr = pictureForm.GetTextPr();
formTextPr.SetItalic(true);
pictureForm.SetTextPr(formTextPr);