Skip to content

Instantly share code, notes, and snippets.

@samtux
Created July 15, 2019 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samtux/9993eddf90158b9c51dfaea432d6b4ca to your computer and use it in GitHub Desktop.
Save samtux/9993eddf90158b9c51dfaea432d6b4ca to your computer and use it in GitHub Desktop.
Extraer el numero de paginas de DOCX
#!/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