Hi
I have a problem which occurs when I have a Custom Document Property that contains a new line. Aspose generates a document that on first sight looks correct but after refreshing the document it looks incorrect. Here is a code snippet which illustrates this problem:
var document = new Document();
var builder = new DocumentBuilder(document);
document.CustomDocumentProperties.Add(“TestProperty”, “Value with\r\nnew line”);
builder.InsertField(@“DOCPROPERTY TestProperty * MERGEFORMAT”);
document.Save(“C:\devNull\testDocProperty.docx”);
After opening the generated file and refreshing the whole document (CTRL+A, F9), the new line is replaced with a character that Word can not display. I’ve attached the generated Aspose document.
Interestingly enough, doing the same using Document Variables works without any problems:
var document = new Document();
var builder = new DocumentBuilder(document);
document.Variables.Add(“TestProperty”, “Value with\r\nnew line”);
builder.InsertField(@“DOCVARIABLE TestProperty * MERGEFORMAT”);
document.Save(“C:\devNull\testDocVariable.docx”);
Is this a known issue or a bug? Am I not able to use new lines safely in a Custom Document Property?
Thank you for your help,
Philipp
Hi Philipp,
Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. The new lines can not be used in a Custom Document Property. You are facing the expected behavior of DOCPROPERTY and TestProperty.
Hi Tahir
Thank you for your reply. I have tried to add a value with a newline to a Custom Document Property via a Word Macro and that works without any problems, including after refreshing the document. This seems inconsistent with how Aspose.Words handles values with a newline.
My macro looks like this:
Sub AddCustomDocumentPropertyTest()
ActiveDocument.CustomDocumentProperties.Add _
Name:=“TestProperty”, _
LinkToContent:=False, _
Type:=msoPropertyTypeString, _
Value:=“Value with” & vbCr & _
"new line"
End Sub
Please see the attached test file, which contains the macro. The document is zipped because I am not allowed to upload a .docm file.
Many thanks,
Philipp
Hi Philipp,
Thanks for sharing the detail.
I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-10414. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.
We apologize for your inconvenience.
The issues you have found earlier (filed as WORDSNET-10414) have been fixed in this .NET update and this Java update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
Hello
This issue is unfortunately still open in Aspose.Words 15.4
Regards,
Hi Philipp,
Thanks for your inquiry. I have tested the scenario using latest version of Aspose.Words for .NET 15.4.0 and have not found the shared issue. I have attached the output document with this post for your kind reference.