Two scripts to make pdf test files.

This commit is contained in:
switham 2014-01-08 22:46:32 -05:00
parent d68183d316
commit d158aa52c1
2 changed files with 54 additions and 0 deletions

35
Sample_Code/makepages.py Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env python
"Make some simple multipage pdf files."
from reportlab.pdfgen import canvas
from sys import argv
point = 1
inch = 72
TEXT = """%s page %d of %d
a wonderful file
created with Sample_Code/makepages.py"""
def make_pdf_file(output_filename, np):
title = output_filename
c = canvas.Canvas(output_filename, pagesize=(8.5 * inch, 11 * inch))
c.setStrokeColorRGB(0,0,0)
c.setFillColorRGB(0,0,0)
c.setFont("Helvetica", 12 * point)
for pn in range(1, np + 1):
v = 10 * inch
for subtline in (TEXT % (output_filename, pn, np)).split( '\n' ):
c.drawString( 1 * inch, v, subtline )
v -= 12 * point
c.showPage()
c.save()
if __name__ == "__main__":
nps = [None, 5, 11, 17]
for i, np in enumerate(nps):
if np:
filename = "simplest_%d.pdf" % i
make_pdf_file(filename, np)
print "Wrote", filename

19
Sample_Code/makesimple.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
n=1
for np in 5 11 17; do
p=1
f=simple$n.pdf
while expr $p \<= $np > /dev/null; do
if [ $p != 1 ]; then
echo " \c"
fi
echo "$f page $p of $np"
echo ""
echo "an incredible, yet simple example"
echo "Created with Sample_Code/makesimple.sh"
p=$(expr $p + 1)
done | enscript --no-header -o - |ps2pdf - $f
echo $f
n=$(expr $n + 1)
done