Skip to content

Add support for setting document properties (Author, Title, etc.) after rendering #77

@vaceslav

Description

@vaceslav

Feature Request

When a document is processed through Templify, the document metadata properties (Author, Title, Subject, etc.) are copied as-is from the source template. There is currently no way to set or override these properties during template processing.

Use Case

Consumers need the ability to set the Author property (and other document metadata) on the output document after rendering. For example, setting the Author to reflect the application that generated the document rather than the original template author.

Proposed Solution

Add a DocumentProperties class to configure document metadata via PlaceholderReplacementOptions:

var options = new PlaceholderReplacementOptions
{
    DocumentProperties = new DocumentProperties
    {
        Author = "My Application"
    }
};

var processor = new DocumentTemplateProcessor(options);
processor.ProcessTemplate(templateStream, outputStream, data);

Properties to support:

  • Author (Creator)
  • Title
  • Subject
  • Description (Comments)
  • Keywords
  • Category
  • LastModifiedBy

Properties left as null should preserve the original template values (backward compatible).

Implementation Notes

  • Uses WordprocessingDocument.PackageProperties (OPC standard API)
  • Applied as a post-processing step alongside UpdateFieldsOnOpen
  • Follows existing patterns: immutable init properties, null = don't touch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions