Last active
July 16, 2016 12:05
-
-
Save silasrm/ff4733ecfa6bf1c6782c3513b89f10c4 to your computer and use it in GitHub Desktop.
Generate many pdf files using a tuple of filename
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
from fpdf import FPDF | |
import re | |
import os | |
""" | |
Generate many files based on a tuple of data for sample. | |
@gist https://gist.github.com/silasrm/ff4733ecfa6bf1c6782c3513b89f10c4 | |
@version 0.1 | |
""" | |
pdf = FPDF() | |
pdf.add_page() | |
pdf.set_font('Arial', 'B', 16) | |
files = ('LS-PM-15/0001.pdf', 'LS-PM-15/0002.pdf', 'LS-PM-15/0003.pdf', 'LS-PM-15/0004.pdf', 'LS-TC-16/0449.pdf', 'LS-TC-16/0450.pdf', 'LS-TC-16/0451.pdf', 'LS-TC-16/0452.pdf', 'LS-PM-15/0005.pdf', 'LS-PM-15/0006.pdf', 'LS-PM-15/0007.pdf', 'LS-PM-15/0008.pdf', 'LS-PM-15/0010.pdf', 'LS-LP-15/9001.pdf', 'LS-TC-15/9001.pdf', 'LS-LP-15/9002.pdf', 'LS-TC-15/9002.pdf', 'LS-LP-15/9003.pdf', 'LS-TC-15/9003.pdf', 'LS-LP-15/9004.pdf', 'LS-TC-15/9004.pdf', 'LS-PM-15/0011.pdf', 'LS-PM-15/0012.pdf', 'LS-PM-15/0013.pdf', 'LS-PM-15/0014.pdf', 'LS-TC-16/454.pdf', 'LS-TC-16/455.pdf', 'LS-TC-16/456.pdf', 'LS-TC-16/457.pdf', 'LS-PM-15/0015.pdf', 'LS-PM-15/0016.pdf', 'LS-TC-15/0412.pdf', 'LS-PM-15/0017.pdf', 'LS-PM-15/0018.pdf', 'LS-PM-15/0019.pdf', 'LS-PM-15/0020.pdf', 'LS-PM-15/0020.pdf', 'LS-PM-15/0021.pdf', 'LS-PM-15/0022.pdf', 'LS-PM-15/0022.pdf', 'LS-PM-15/0023.pdf', 'LS-PM-15/0024.pdf', 'LS-PM-15/0025.pdf', 'LS-PM-15/0026.pdf', 'LS-PM-15/0027.pdf', 'LS-PM-15/0028.pdf', 'LS-PM-15/0029.pdf', 'LS-PM-15/0030.pdf', 'LS-PM-15/0031.pdf', 'LS-PM-15/0032.pdf', 'LS-PM-15/0033.pdf', 'LS-PM-15/0034.pdf', 'LS-PM-15/0035.pdf', 'LS-PM-15/0036.pdf', 'LS-PM-15/0037.pdf', 'LS-PM-15/0038.pdf', 'LS-PM-15/0039.pdf', 'LS-PM-15/0040.pdf', 'LS-PM-15/0041.pdf', 'LS-PM-15/0042.pdf', 'LS-PM-15/0043.pdf', 'LS-PM-15/0044.pdf', 'LS-PM-15/0045.pdf', 'LS-PM-15/0046.pdf', 'LS-PM-15/0047.pdf', 'LS-PM-15/0048.pdf', 'LS-PM-15/0049.pdf', 'LS-PM-15/0050.pdf', 'LS-PM-15/0051.pdf', 'LS-PM-15/0052.pdf', 'LS-PM-15/0053.pdf') | |
for f in files: | |
name = f.split('/') | |
if not os.path.isdir('./' + name[0]): | |
os.makedirs(name[0]) | |
pdf.cell(40, 10, 'Arquivo ' + f) | |
pdf.output(f, 'F') | |
print 'criado arquivo ' + f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment