Pipeline publishing
Revision as of 16:39, 21 June 2011 by Mirjam Dissel (talk | contribs)
apt-get install pdftk inkscape
The publishing part
import codecs, page, os, sys
send = 'lpr -P %s %s'
f = codecs.open('test.script', 'r', 'utf-8')
p = 0
for line in f:
line = line.strip()
if not line:
continue
(speaker, text) = line.split('|', 1)
p += 1
print p, speaker, text
svgname = 'page%04d.svg' % p
pdfname = 'page%04d.pdf' % p
out = codecs.open('svg/'+svgname, 'w', 'utf-8')
page.dump(out, text, p)
out.close()
os.system(' inkscape svg/%s --export-pdf=svg/%s' % (svgname, pdfname))
os.system(' pdftk svg/%s cat 1-endS output final/%s' % (pdfname, pdfname))
The svg template (page.py):
def dump (f, text, page):
f.write("""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="524.40942"
height="744.09448"
id="svg2"
version="1.1"
inkscape:version="0.47 r22583"
sodipodi:docname="New document 1">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.61742627"
inkscape:cx="80.403821"
inkscape:cy="217.57273"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1511"
inkscape:window-height="910"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-308.26769)">
<flowRoot
xml:space="preserve"
id="flowRoot2816"
style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
transform="translate(0,308.26769)"><flowRegion
id="flowRegion2818"><rect
id="rect2820"
width="445.39731"
height="553.91229"
x="34.012157"
y="83.286842" /></flowRegion><flowPara
id="flowPara2822" /></flowRoot> <flowRoot
xml:space="preserve"
id="flowRoot2824"
style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
transform="translate(1.3658447,425.26064)"><flowRegion
id="flowRegion2826"><rect
id="rect2828"
width="453.49545"
height="524.75903"
x="34.012157"
y="62.231693" /></flowRegion><flowPara
id="flowPara2830"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;text-anchor:middle;font-family:Georgia;-inkscape-font-specification:Georgia">""")
f.write(text)
f.write("""</flowPara></flowRoot> <flowRoot
xml:space="preserve"
id="flowRoot2832"
style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
transform="translate(20.931274,308.26769)"><flowRegion
id="flowRegion2834"><rect
id="rect2836"
width="119.85236"
height="69.643944"
x="181.39818"
y="651.77576" /></flowRegion><flowPara
id="flowPara2838"
style="font-size:28px;text-align:center;text-anchor:middle;font-family:Georgia;-inkscape-font-specification:Georgia">""")
f.write(str(page))
f.write("""</flowPara></flowRoot> </g>
</svg>""")