This project has moved and is read-only. For the latest updates, please go here.

Addcustomproperty not showing values in header



i have 4 custom properties in my header, when i run the code im not getting any values in header. if i place the same custom properties out side the header( normal work space) i can get the values.

plx help me in solving this i was stuck with this from past 2 days and im trying all possible ways to slove this.

your help is highly appreciated. Thanks


BoucherS wrote Apr 25, 2017 at 9:04 PM


What code do you use.

This looks good :
// Loading the file
      _document = DocX.Load( @"test.docx" );
      // Add a custom property
      _document.AddCustomProperty( new CustomProperty( "AAA", "Xceed Software inc." ) );

      // in document
      _document.Paragraphs[ 8 ].AppendDocProperty( _document.CustomProperties["AAA"] );
      // in document header
      _document.Headers.Odd.Paragraphs.Last().AppendDocProperty( _document.CustomProperties[ "AAA" ] );

      _document.SaveAs( @"test5.docx" );