Skip to content

Add more core properties #911

Open
Open

Description

@tuhalang

Please add properties company, manager into core properties

Activity

  1. jacbeekers commented on Jan 30, 2021

    @jacbeekers

    I was also looking for that information, but found out that actually Company and Manager are not in openxml core-properties, but in openxml extended-properties. Hence, I would not expect these items to be added to core-properties, although in Word these are display in tab dialog 'Properties'.
    ref: https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.extendedproperties?view=openxml-2.8.1

  2. tuhalang commented on Jan 30, 2021

    @tuhalang
    Author

    I figured out how to change this property by editing app.xml

  3. samskyy commented on Mar 11, 2021

    @samskyy

    @tuhalang could you please share how did you solve it?

  4. tuhalang commented on Mar 11, 2021

    @tuhalang
    Author

    @samskyy I use this to change Company Properties:

    def unzip(file, name):
    with zipfile.ZipFile(file, 'r') as zip_ref:
    zip_ref.extractall('out/'+name)

    def zipfolder(foldername, target_dir):
    zipobj = zipfile.ZipFile(foldername, 'w', zipfile.ZIP_DEFLATED)
    rootlen = len(target_dir) + 1
    for base, dirs, files in os.walk(target_dir):
    for file in files:
    fn = os.path.join(base, file)
    zipobj.write(fn, fn[rootlen:])

    def change_company(file, name, company):
    unzip(file, name)
    path = 'out\'+name+'\docProps\app.xml'
    xmlTree = et.parse(path)
    rootElement = xmlTree.getroot()
    for i in range(20):
    if rootElement[i].tag.endswith('Company'):
    rootElement[i].text = company
    break
    xmlTree.write(path,encoding='UTF-8',xml_declaration=True)
    zipfolder(file, 'out\'+name)
    shutil.rmtree('out\'+name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions