GetShd
Gets the text shading from the current text properties.
Syntax
expression.GetShd();
expression - A variable that represents a ApiTextPr class.
Parameters
This method doesn't have any parameters.
Returns
Shd | undefined
Example
Read the background shading applied to a run of text in a document.
// How do I find out what shading color and pattern are set on a piece of text in a document?
// Copy the shading from one text run and apply it to another run in a document.
let doc = Api.GetDocument();
let firstParagraph = doc.GetElement(0);
let myNewRunStyle = doc.CreateStyle('My New Run Style', 'run');
let styleTextPr = myNewRunStyle.GetTextPr();
styleTextPr.SetCaps(true);
styleTextPr.SetFontFamily('Calibri Light');
let firstRun = Api.CreateRun();
firstRun.AddText('This is just a sample text. ');
firstParagraph.AddElement(firstRun);
let secondRun = Api.CreateRun();
secondRun.SetStyle(myNewRunStyle);
secondRun.AddText('A text run with shd applied to it.');
let secondRunTextPr = secondRun.GetTextPr();
secondRunTextPr.SetShd('clear', Api.RGBA(255, 111, 61));
firstParagraph.AddElement(secondRun);
let shd = secondRunTextPr.GetShd();
let secondParagraph = Api.CreateParagraph();
let thirdRun = Api.CreateRun();
thirdRun.AddText('This run has the shading from the last run in the first paragraph.');
let thirdRunTextPr = thirdRun.GetTextPr();
thirdRunTextPr.SetShd(shd.Type, shd.Color);
secondParagraph.AddElement(thirdRun);
doc.Push(secondParagraph);