BuiltInDocumentPropertiesContentType Property |
Gets or sets the ContentStatus of the document.
Syntax
public string ContentType { get; set; }
Public Property ContentType As String
Get
Set
public:
property String^ ContentType {
String^ get ();
void set (String^ value);
}
member ContentType : string with get, set
Property Value
Type:
String
Examples
Shows how to work with document properties in the "Content" category.
public void Content()
{
Document doc = new Document(MyDir + "Paragraphs.docx");
BuiltInDocumentProperties properties = doc.BuiltInDocumentProperties;
Assert.AreEqual(6, properties.Pages);
doc.UpdateWordCount();
Assert.AreEqual(1035, properties.Words);
Assert.AreEqual(6026, properties.Characters);
Assert.AreEqual(7041, properties.CharactersWithSpaces);
LineCounter lineCounter = new LineCounter(doc);
properties.Lines = lineCounter.GetLineCount();
Assert.AreEqual(142, properties.Lines);
properties.Paragraphs = doc.GetChildNodes(NodeType.Paragraph, true).Count;
Assert.AreEqual(29, properties.Paragraphs);
Assert.AreEqual(20310, properties.Bytes);
doc.AttachedTemplate = MyDir + "Business brochure.dotx";
Assert.AreEqual("Normal", properties.Template);
properties.Template = doc.AttachedTemplate;
properties.ContentStatus = "Draft";
Assert.AreEqual(string.Empty, properties.ContentType);
Assert.False(properties.LinksUpToDate);
doc.Save(ArtifactsDir + "DocumentProperties.Content.docx");
}
private class LineCounter
{
public LineCounter(Document doc)
{
mLayoutEnumerator = new LayoutEnumerator(doc);
CountLines();
}
public int GetLineCount()
{
return mLineCount;
}
private void CountLines()
{
do
{
if (mLayoutEnumerator.Type == LayoutEntityType.Line)
{
mScanningLineForRealText = true;
}
if (mLayoutEnumerator.MoveFirstChild())
{
if (mScanningLineForRealText && mLayoutEnumerator.Kind.StartsWith("TEXT"))
{
mLineCount++;
mScanningLineForRealText = false;
}
CountLines();
mLayoutEnumerator.MoveParent();
}
} while (mLayoutEnumerator.MoveNext());
}
private readonly LayoutEnumerator mLayoutEnumerator;
private int mLineCount;
private bool mScanningLineForRealText;
}
See Also