We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

BuiltInDocumentProperties.Author not exported to ODT?

If I place an author field in the document I create, and set the document author via BuiltInDocumentProperties.Author, and save as ODT, I find that the DocInformation:Created (Author) field is present in the output document, but I can't get it to display the author name I supplied in BuiltInDocumentProperties.Author. Could it be that BuiltInDocumentProperties.Author is not translating to ODT?

Below is code that reproduces the problem.

static void doDoc()
Document _toDoc = new Document();
_toDoc.BuiltInDocumentProperties.Title = "hello";
_toDoc.BuiltInDocumentProperties.Author = "me";
_toDoc.BuiltInDocumentProperties.Pages = 1;
_toDoc.BuiltInDocumentProperties.NameOfApplication = "foo";
_toDoc.RemoveAllChildren(); // removes default section
Section _section = new Section(_toDoc);
Body body = new Body(_toDoc);
_section.PageSetup.LeftMargin = 72.0;
_section.PageSetup.TopMargin = 72.0;
_section.PageSetup.RightMargin = 72.0;
_section.PageSetup.BottomMargin = 72.0;
_section.PageSetup.PageWidth = 612.0;
_section.PageSetup.PageHeight = 792.0;
_section.PageSetup.HeaderDistance = 20.0;
_section.PageSetup.FooterDistance = 20.0;

addParagraph(_toDoc, body);
_toDoc.Save("c:\\temp\\test.odt", SaveFormat.Odt);

static void addParagraph(Document _toDoc, Body body)
Paragraph asposePara = new Paragraph(_toDoc);
asposePara.ParagraphFormat.FirstLineIndent = 0.0;
asposePara.ParagraphFormat.LeftIndent = 0.0;
asposePara.ParagraphFormat.RightIndent = 0.0;
TabStop stop = new TabStop(36.0);
stop.Alignment = TabAlignment.Left;
asposePara.ParagraphFormat.Alignment = ParagraphAlignment.Left;
asposePara.ParagraphFormat.LineSpacing = 12.0;
asposePara.ParagraphFormat.SpaceAfter = 0.0;
asposePara.ParagraphFormat.SpaceBefore = 0.0;
Run asposeRun = new Run(_toDoc, "hello");
asposeRun.Font.Name = "Times New Roman";
asposeRun.Font.Size = 12.0;

DocumentBuilder builder = new DocumentBuilder(_toDoc);
string fieldCode = @"SAVEDATE \@ ""MMMM d, yyyy"" \* MERGEFORMAT";
string fieldValue = DateTime.UtcNow.ToString("MMMM d, yyyy");
builder.InsertField(fieldCode, fieldValue);
fieldCode = @"AUTHOR \* MERGEFORMAT";
fieldValue = "Bartholomew";
builder.InsertField(fieldCode, fieldValue);

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I see that BuildeInDocumentProperties are not displayed in “Properties/DocumentStatistics”. I created new issue #5552 in our defect database. Is it what you meant? See attached image.

Best regards


OpenOffice Writer save to ODT without Unicode byte order mark (the first three bytes of XML files - EF BB BF for UTF-8), while Aspose.Words save with it.

The document statistics is not displayed because meta.xml part of ODT package contain Unicode byte order mark.

We will fix it in the next release.

I want to clarify that my original issue was that an DocInformation:Created (Author) field in the document didn't have the actual Author value displayed. Will this fix make that work too?


Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I tried to insert Author field using menu Insert/Fields/Other/DocInformation/Created/Author and this field displays correct value “me”.

In your code you are inserting this field using the following code:

fieldCode = @"AUTHOR \* MERGEFORMAT";

fieldValue = "Bartholomew";

builder.InsertField(fieldCode, fieldValue);

It seems that OpenOfice updates all fields during opening document. So in the document you see “me” (value inserted into _toDoc.BuiltInDocumentProperties.Author = "me";) instead “Bartholomew”.

Best regards.

The behavior I'm seeing when I run the code I gave is that when I open test.odt in OpenOffice Writer 2.4, the fields are present (I can see them both by selecting the View/Field Names menu), but the DocInformation:Created field has no value when I turn off View/Field Names.

Even if I then insert a new field using Insert/Fields/Author, there's no value showing for that new field.

Just the same, I can see that Document/Properties shows "me" as the author.

See attached files.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for additional information. I managed to reproduce the issue. But on my side DocInformation:Modified disappears. I use OpenOfice 2.2.1. I will try this using Open Ofice 2.4.1 and provide you more information.

Best regards.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I consulted with responsible developer. It seems that OpenOffice works not correctly with documents with created date is least than 1583. So as a workaround you can check created date and set it if it is least than 1583. Please see the following example:

DateTime time = new DateTime(1583, 1, 1);

if (_toDoc.BuiltInDocumentProperties.CreatedTime < time)

_toDoc.BuiltInDocumentProperties.CreatedTime = DateTime.Now;

_toDoc.BuiltInDocumentProperties.LastSavedTime = DateTime.Now;

Please let me know if this helps.

Best regards.

The issues you have found earlier (filed as 5552) have been fixed in this update. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />