Answers for "WordWrapper 2.0?" https://knowledge.亚搏在线safe.com/questions/37001/wordwrapper-20.html The latest answers for the question "WordWrapper 2.0?" Answer by itay https://knowledge.safe.com/answers/37013/view.html

It still there on theFME hub

Mon, 28 Nov 2016 17:02:21 GMT itay
Answer by david_r https://knowledge.safe.com/answers/37005/view.html

I posted this a long time ago, but it's not easily searchable and the code has been mangled while ported between the different versions of the forum software, so here's a slightly modified version of my original post.

You can insert the following code into a PythonCaller, it will read a string from the attribute "text_line_data" and wrap it at the position specified in a parameter "MaxWidth":

import fmeobjects import textwrap def TextWrapper(feature): text = feature.getAttribute("text_line_data") # modify as necessary maxLength = int(FME_MacroValues['MaxWidth']) parts = textwrap.wrap(text, maxLength) feature.setAttribute('number_of_parts', len(parts)) if parts: feature.setAttribute('parts{}', parts)

Expose the attributes "parts{}" and "number_of_parts" in the PythonCaller.

This outputs all parts to the list "parts{}", you can then use a ListExploder to get one feature per wrapped line, see attached sample workspace.

textwrapper.fmwt

Mon, 28 Nov 2016 16:17:44 GMT david_r
Answer by corrado https://knowledge.safe.com/answers/37003/view.html

It seem you need "SubstringExtractor" transformer.

Mon, 28 Nov 2016 16:14:14 GMT corrado