Created
July 15, 2019 18:56
-
-
Save samtux/9993eddf90158b9c51dfaea432d6b4ca to your computer and use it in GitHub Desktop.
Extraer el numero de paginas de DOCX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Mon Jul 15 12:26:25 2019 | |
@author: samtux | |
""" | |
import zipfile | |
import xml.etree.ElementTree as ET | |
documento = "/home/samtux/Documentos/Plantilla_elaboracion_documentos.docx" | |
zf = zipfile.ZipFile(documento, 'r') | |
root = ET.fromstring(zf.read("docProps/app.xml").decode('utf-8')) | |
total_paginas = 0 | |
for child in root: | |
if child.tag.find("Pages") > -1: | |
total_paginas = int(child.text) | |
print("*"*20) | |
print(total_paginas) | |
print("*"*20) | |
zf.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment