Please add properties company, manager into core properties
Activity
jacbeekers commentedon Jan 30, 2021
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
tuhalang commentedon Jan 30, 2021
I figured out how to change this property by editing app.xml
samskyy commentedon Mar 11, 2021
@tuhalang could you please share how did you solve it?
tuhalang commentedon Mar 11, 2021
@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)