WPCubed Product Support

Keep the style of the text when using InputTextFieldName

Hello.

My problem seems really simple, but I'm stuck.
In the following code, during a merge I add a field "NUMPAGES" or text as appropriate.

void __fastcall ConvertirModele::OnMergeGetTextEvent(System::TObject * Sender, const System::UnicodeString inspname, TWPMMInsertTextContents * Contents)
	{
	if (inspname=="NUM_PAGE")
		{
		Contents->InputTextFieldName("NUMPAGES");
		}
	else	if (inspname=="TEXTE"))
		{
		Contents->StringValue = "Texte";
		}
	}

In case I use the InputTextFieldName function, the font of the variable is not resumed. The result is always in Arial, Size 11, Color Black.
When I assign my text to the StringValue property, the original font is always preserved.

How to apply the original font to the new field created ?

Thank you for your reply.

#1 ♥ 0
5.6k Views 2 users read 1 min
support

You can do this:

WPRichText1.WritingAttr.Assign(Contents.MergeAttr);
WPRichText1.InputTextFieldName('NUMPAGES');

instead.

#2 ♥ 0

Hello.

Thank you.

This is not the ideal solution for me because I do not have direct access to the TWPRichText in my OnMergeGetTextEvent function. I would have liked to see access to it using the parameters of the function but I will go through global variables to solve the problem.

#3 ♥ 0
support

WritingAttr is accessible through

TParagraph.RTFData.DataCollection.DefaultAttr

#4 ♥ 0
This category is archived. No new posts are possible.