Free Support Forum - aspose.com

Strange issue with Custom Document Properties

I am having a weird issue with custom document properties. I have a method called EmbedPrinterInfo that takes and Aspose.Word document object, a printer name (string) and an integer for the number of copies. The code for the method is pasted below:


public static Document EmbedPrinterInfo(Document myDoc, string PrinterName, int NumberOfCopies)

{

if (myDoc.CustomDocumentProperties["DocPrinter"] != null)

{

myDoc.CustomDocumentProperties["DocPrinter"].Value = PrinterName;

}

else { myDoc.CustomDocumentProperties.Add("DocPrinter", PrinterName); }

if (myDoc.CustomDocumentProperties["PrintCopies"] != null)

{

myDoc.CustomDocumentProperties["PrintCopies"].Value = NumberOfCopies;

}

else { myDoc.CustomDocumentProperties.Add("PrintCopies", NumberOfCopies); }

return myDoc;

}


I have stepped through my code numerous times and have verified that all lines in this method are executing as expected. The problem is that only the second custom property 'PrintCopies' ever shows up in the document. 'DocPrinter' never shows up at all in the document, even though the line to add it executes the same as the 'PrintCopies' property. Any ideas as to why this may be? I am using Aspose.Word version 2.4.1


Hi,

Thank you for considering Aspose.

Please try to download the latest version of the component first, it should help because we’ve fixed the custom properties bug in v2.5.

Upgrading to the latest version (2.5) fixed my problem.

Thanks.