Solved! Go to Solution.
def cloneText(txtElement, x, y, string): condoText_clone = txtElement.clone() condoText_clone.elementPositionX = x condoText_clone.elementPositionY = y condoText_clone.text = string desc = row.getValue("LegalDesc") wrapLines = textwrap.wrap(desc, 50) for line in wrapLines: cloneText(legalDesc, x, y, line) y = y - legalDesc.elementHeight - y3
If the objective is to fit variable length text into a limited area on a page layout and reduce the size of the text when necessary, it can be done using Python but requires some coding gymnastics.
Here is a snippet of code that reads a string from a field and via the textwrap module, it breaks the code up into an appropriate number of lines.def cloneText(txtElement, x, y, string): condoText_clone = txtElement.clone() condoText_clone.elementPositionX = x condoText_clone.elementPositionY = y condoText_clone.text = string desc = row.getValue("LegalDesc") wrapLines = textwrap.wrap(desc, 50) for line in wrapLines: cloneText(legalDesc, x, y, line) y = y - legalDesc.elementHeight - y3
Where this can get more involved is if you want to test multiple variables ahead of time (e.g., total width vs total height) to optimize the text within the designated area. It can be an iterative process to modify the fontsize and retest for fitting strategies.
Jeff