Permalink
Browse files

I forgot to add this directory to git

  • Loading branch information...
1 parent 1386b06 commit b9fc0ee7b488d626b3c1df73bb85241f9b8c8284 @comex committed Jul 21, 2011
Showing with 130 additions and 0 deletions.
  1. +20 −0 pdf/mkpdf.py
  2. +110 −0 pdf/out.pdf.template
View
@@ -0,0 +1,20 @@
+import zlib, sys, re, struct
+u = open(sys.argv[1], 'rb').read()
+z = zlib.compress(u, 9)
+
+m = re.search('currentfile eexec[\r\n]*', u)
+encstart = m.end()
+assert u[encstart:encstart+2] == '\x80\x02'
+encend = encstart + 6 + struct.unpack('<I', u[encstart+2:encstart+6])[0]
+zeroes = u.find('0000000', encend)
+
+fmt = {}
+fmt['length'] = len(z)
+fmt['length1'] = encstart
+fmt['length2'] = zeroes - encstart
+fmt['length3'] = len(u) - zeroes
+fmt['stream'] = z
+
+pdf = open('out.pdf.template', 'rb').read().format(**fmt)
+open(sys.argv[2], 'wb').write(pdf)
+
View
@@ -0,0 +1,110 @@
+%PDF-1.3
+%����
+2 0 obj
+<<
+/Length 61
+>>
+stream
+BT
+/TT2 1 Tf
+32 0 0 32 0 0 Tm
+0 g
+/GS1 gs
+0 Tc
+0 Tw
+(@)Tj
+ET
+endstream
+endobj
+3 0 obj
+<<
+/ProcSet [/PDF /Text ]
+/Font <<
+/TT2 4 0 R
+>>
+>>
+endobj
+7 0 obj
+<<
+/Type /FontDescriptor
+/Ascent 750
+/CapHeight 676
+/Descent -250
+/Flags 32
+/FontBBox [-203 -428 1700 1272]
+/ItalicAngle 0
+/StemV 0
+/MaxWidth 1721
+/XHeight 461
+/FontName /Courier10PitchBT-Italic
+/Length1 {length1}
+/Length2 {length2}
+/Length3 {length3}
+/FontFile 12 0 R
+>>
+endobj
+4 0 obj
+<<
+/Type /Font
+/Subtype /Type1
+/FirstChar 64
+/LastChar 64
+/Widths [100]
+/BaseFont /Courier10PitchBT-Italic
+/FontDescriptor 7 0 R
+>>
+endobj
+1 0 obj
+<<
+/Type /Page
+/Parent 6 0 R
+/Resources 3 0 R
+/Contents 2 0 R
+>>
+endobj
+8 0 obj
+<<
+/S /D
+>>
+endobj
+9 0 obj
+<<
+/Nums [0 8 0 R ]
+>>
+endobj
+6 0 obj
+<<
+/Type /Pages
+/Kids [1 0 R]
+/Count 1
+/MediaBox [0 0 30 20]
+>>
+endobj
+11 0 obj
+<<
+/Type /Catalog
+/Pages 6 0 R
+/PageLabels 9 0 R
+>>
+endobj
+12 0 obj
+<<
+/Filter[/FlateDecode]
+/Length {length}
+/Length1 {length1}
+/Length2 {length2}
+/Length3 {length3}
+>>
+stream
+{stream}
+endstream
+endobj
+xref
+trailer
+<<
+/Size 12
+/Root 11 0 R
+>>
+startxref
+1131
+%%EOF

0 comments on commit b9fc0ee

Please sign in to comment.