Created
May 22, 2020 00:31
-
-
Save imesut/add4c438e77429fef3cc94676e31a954 to your computer and use it in GitHub Desktop.
Generate PDFs with custom field from pptx → odp
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
import zipfile, os | |
codes = ["insert", "codes", "here"] | |
prevcode = "XXXXXXX" | |
count = 1 | |
for code in codes: | |
with open("template/content.xml", "r") as codefileR: | |
newcontent = codefileR.read().replace(prevcode, code) | |
with open("template/content.xml", "w") as codefileW: | |
codefileW.write(newcontent) | |
generatedfile = zipfile.ZipFile(str(count) + '.odp', 'w') | |
for root, dirs, files in os.walk("template/"): | |
for file in files: | |
generatedfile.write(os.path.join(root, file),os.path.join(root, file).replace("template/","")) | |
generatedfile.close() | |
count += 1 | |
prevcode = code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment