Structured Document Tags and Placeholder texts?

Hi,
sdt.PlaceholderName = “” does not appear to do what I want.

How do I clear the placeholder name so that it has none and defaults to the 5 non-breaking spaces instead of the “Enter Text Here” default provided by Aspose?

Per the ECMA Office Open XML Part 1:

17.5.2.25 placeholder (Structured Document Tag Placeholder Text)
This element specifies the placeholder text which should be displayed when this structured document tag’s run
contents are empty, the associated mapped XML element is empty as specified via the dataBinding element
(§17.5.2.6) or the showingPlcHdr element (§17.5.2.39) is set in the structured document tag’s properties. The
placeholder text which shall be shown is itself specified via the child element docPart.
If this element is omitted, then five non-breaking spaces shall be used as the default placeholder text for this
structured document tag.

How do I tell Aspose to not generate a placeholder xml element?

Thanks,
Andy Bay

Hi Andy,

Thanks for your inquiry. Please set the value of StructuredDocumentTag.IsShowingPlaceholderText property to false and replace placeholder’s text as shown below. Hope this helps you.

var doc = new Aspose.Words.Document();
var builder = new Aspose.Words.DocumentBuilder(doc);
var structuredDocumentTag = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Inline);
structuredDocumentTag.IsShowingPlaceholderText = false;
structuredDocumentTag.Placeholder.Range.Replace("Click here to enter text.", "", new FindReplaceOptions());
structuredDocumentTag.ChildNodes.Clear();
if (structuredDocumentTag.Level == MarkupLevel.Inline)
    structuredDocumentTag.AppendChild(new Run(doc, string.Format("content of content control #{0}", structuredDocumentTag.Id)));
doc.FirstSection.Body.FirstParagraph.AppendChild(structuredDocumentTag);
doc.Save(MyDir + "Out v16.11.0.docx");

Sadly, that kinda works, and I’m doing something similar, but it does not solve the actual goal.
But this solution is all-or-nothing because it modifies the default placeholder text.
Also, this solution forces the placeholder to use its own formatting while the no-placeholder option makes Word use the local formatting.

The statement structuredDocumentTag.IsShowingPlaceholderText = false; removes the “showingPlcHdr” tag, not the placeholder tag.
I want a sdt.UsePlaceholder boolean that disables the “placeholder” tag completely
Or implement and document that sdt.placeholderName = null to do that.

Thanks,
Andy Bay

Hi Andy,

Thanks for your inquiry. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

The simple word doc.

Example of an empty SDT, showing the placeholder, but having no actual placeholder defined:

<w:sdt>
	<w:sdtPr>
		<w:alias w:val="No Placeholder"/>
		<w:tag w:val="sdtNoPlaceholder"/>
		<w:id w:val="-2020763619"/>
		<w:showingPlcHdr/>
	</w:sdtPr>
	<w:sdtEndPr/>
	<w:sdtContent>
		<w:r w:rsidR="005C1F4E">
			<w:t xml:space="preserve"> </w:t>
		</w:r>
	</w:sdtContent>
</w:sdt>

Example of an SDT with an empty placeholder, but currently having real content:

<w:sdt>
	<w:sdtPr>
		<w:alias w:val="No Placeholder 2"/>
		<w:tag w:val="sdtNoPlaceholder2"/>
		<w:id w:val="764504923"/>
		<w:lock w:val="sdtLocked"/>
	</w:sdtPr>
	<w:sdtContent>
		<w:r>
			<w:t>This has real content, but no placeholder.</w:t>
		</w:r>
	</w:sdtContent>
</w:sdt>

(Note, this one is locked so you don’t accidentally delete the control while trying to get the intended result that should look basically like the one above.)

Thanks,
Andy Bay

Hi Andy,

Thanks for sharing the document. We have logged this feature request as WORDSNET-14533 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

@andrew.bay.ctr,

The issues you have found earlier (filed as WORDSNET-14533) have been fixed in this Aspose.Words for .NET 17.9 update and this Aspose.Words for Java 17.9 update.