Hi,
just struggled a bit with the placeholder text for “plain text” input fields: in a german word installation, they have the placeholder text “Klicken oder tippen Sie hier, um Text einzugeben.”. But when creating a StructuredDocumentTag using Aspose.Words, it has the default text “Click here to enter text”.
It would be perfect if Aspose.Words could create those placeholders based on the current locale: doc.Styles.DefaultFont.LocaleId = (int)EditingLanguage.GermanGermany;
I found a workaround, based on https://reference.aspose.com/net/words/aspose.words.markup/structureddocumenttag/properties/placeholder
Unfortunately, those placeholders will have black font instead of gray.
I managed to set the the style to the builtin style “Placeholder text”, and now I have german texts in the expected color.
Here is the full code:
StructuredDocumentTag textBox2 = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);
GlossaryDocument glossaryDoc = doc.GlossaryDocument;
BuildingBlock substituteBlock = new BuildingBlock(glossaryDoc);
substituteBlock.Name = "Custom Placeholder";
substituteBlock.AppendChild(new Section(glossaryDoc));
substituteBlock.FirstSection.AppendChild(new Body(glossaryDoc));
Paragraph p = substituteBlock.FirstSection.Body.AppendParagraph("Text eingeben.");
p.Runs[0].Font.StyleIdentifier = StyleIdentifier.PlaceholderText;
glossaryDoc.AppendChild(substituteBlock);
textBox2.PlaceholderName = "Custom Placeholder";
docBuilder.InsertNode(textBox2);
Attached is also a full sample.
AsposeWordsPlaceholder.zip (4.9 MB)
Is there a better workaround for german textbox texts?
Maybe someone finds this post helpful - at least I did not find this information ;-), and maybe the Aspose guys have some idea to improve this. It would be ideal if the text box has the correct localized text by default.
Best regards
Wolfgang