-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I forgot to add this directory to git
- Loading branch information
Showing
2 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |