TG-35 : Typo

This commit is contained in:
Clément ARNAUDEAU
2017-01-23 15:50:20 +01:00
9 changed files with 105 additions and 5 deletions

View File

@ -0,0 +1,25 @@
#pdfjinja 1.0.0
##Dependencies :
python-dev
python-pip
libtiff5-dev
libjpeg8-dev
zlib1g-dev
libfreetype6-dev
liblcms2-dev
libwebp-dev
tcl8.6-dev
tk8.6-dev
python-tk
pdftk
libmagickwand-dev
##Installation:
pip install pdfjinja
##Test :
pdfjinja -h

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
""" Script python qui remplie les pdf basés sur un template jinja. """
import os
from pdfjinja import PdfJinja
def remplirTemplate (dirname_template, pdf_template, dirname_output_file, pdf_output,dictionnaire):
"""
Fonction qui permet de remplir un pdf template
:param dirname_template: chemin du fichier de template
:param pdf_template: nom du fichier de template
:param dirname_output_file: chemin des pdf généré
:param pdf_output: nom du fichier pdf à générer
:param dictionnaire: dictionnaire contenant le nom des textfields des pdf ainsi que leurs valeurs
:return:
"""
template_pdf_file = os.path.join(dirname_template, pdf_template)
template_pdf = PdfJinja(template_pdf_file)
rendered_pdf = template_pdf(dictionnaire)
output_file = os.path.join(dirname_output_file, pdf_output)
rendered_pdf.write(open(output_file, 'wb'))

View File

@ -5,11 +5,11 @@ from hashlib import sha512
SIMPLE_CHARS = string.ascii_letters + string.digits
def get_random_string(length=24):
def get_random_string(length=32):
return ''.join(random.choice(SIMPLE_CHARS) for i in range(length))
def get_random_hash(length=24):
def get_random_hash(length=64):
hash = sha512()
hash.update(get_random_string())
return hash.hexdigest()[:length]