mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 08:34:23 +08:00
test: trivial synthetic pdf for completing structure coverage
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
%PDF-1.4
|
||||
1 0 obj
|
||||
<< /Type /Catalog
|
||||
/Outlines 2 0 R
|
||||
/Pages 3 0 R
|
||||
/StructTreeRoot 7 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
2 0 obj
|
||||
<< /Type /Outlines
|
||||
/Count 0
|
||||
>>
|
||||
endobj
|
||||
|
||||
3 0 obj
|
||||
<< /Type /Pages
|
||||
/MediaBox [0 0 612 792]
|
||||
/Kids [4 0 R 11 0 R]
|
||||
/Count 2
|
||||
>>
|
||||
endobj
|
||||
|
||||
4 0 obj
|
||||
<< /Type /Page
|
||||
/Parent 3 0 R
|
||||
/Contents 6 0 R
|
||||
/StructParents 0
|
||||
/Resources << /ProcSet [/PDF /Text]
|
||||
/Font << /F1 5 0 R >>
|
||||
>>
|
||||
>>
|
||||
endobj
|
||||
|
||||
5 0 obj
|
||||
<< /Type /Font
|
||||
/Subtype /Type1
|
||||
/Name /F1
|
||||
/BaseFont /Helvetica
|
||||
>>
|
||||
endobj
|
||||
|
||||
6 0 obj
|
||||
<< /Length 87 >>
|
||||
stream
|
||||
/P <</MCID 1>> BDC
|
||||
BT
|
||||
/F1 24 Tf
|
||||
100 700 Td
|
||||
(Hello World) Tj
|
||||
ET
|
||||
EMC
|
||||
endstream
|
||||
endobj
|
||||
|
||||
7 0 obj
|
||||
<< /Type /StructTreeRoot
|
||||
/ParentTree 8 0 R
|
||||
/RoleMap << /Title /P >>
|
||||
/ClassMap << /C1 << /O /Foo /A1 1 >> >>
|
||||
/K [9 0 R]
|
||||
>>
|
||||
endobj
|
||||
|
||||
8 0 obj
|
||||
<< /Nums [
|
||||
0 [10 0 R]
|
||||
1 [13 0 R]
|
||||
]
|
||||
>>
|
||||
endobj
|
||||
|
||||
9 0 obj
|
||||
<< /Type /StructElem
|
||||
/S /Document
|
||||
/P 7 0 R
|
||||
/K [10 0 R 13 0 R]
|
||||
>>
|
||||
endobj
|
||||
|
||||
10 0 obj
|
||||
<< /Type /StructElem
|
||||
/S /Title
|
||||
/P 9 0 R
|
||||
/Pg 4 0 R
|
||||
/C /C1
|
||||
/K [1]
|
||||
>>
|
||||
endobj
|
||||
|
||||
11 0 obj
|
||||
<< /Type /Page
|
||||
/Parent 3 0 R
|
||||
/Contents 12 0 R
|
||||
/StructParents 1
|
||||
/Resources << /ProcSet [/PDF /Text]
|
||||
/Font << /F1 5 0 R >>
|
||||
>>
|
||||
>>
|
||||
endobj
|
||||
|
||||
12 0 obj
|
||||
<< /Length 101 >>
|
||||
stream
|
||||
/P <</MCID 1>> BDC
|
||||
BT
|
||||
/F1 24 Tf
|
||||
100 700 Td
|
||||
(Goodbye Cruel World) Tj
|
||||
ET
|
||||
endstream
|
||||
EMC
|
||||
endobj
|
||||
|
||||
13 0 obj
|
||||
<< /Type /StructElem
|
||||
/S /Title
|
||||
/P 9 0 R
|
||||
/Pg 11 0 R
|
||||
/K [1]
|
||||
/C /C1
|
||||
/A << /A1 2 /A2 2 >>
|
||||
>>
|
||||
endobj
|
||||
|
||||
xref
|
||||
0 14
|
||||
0000000000 65535 f
|
||||
0000000009 00000 n
|
||||
0000000116 00000 n
|
||||
0000000172 00000 n
|
||||
0000000280 00000 n
|
||||
0000000481 00000 n
|
||||
0000000581 00000 n
|
||||
0000000720 00000 n
|
||||
0000000882 00000 n
|
||||
0000000975 00000 n
|
||||
0000001075 00000 n
|
||||
0000001195 00000 n
|
||||
0000001398 00000 n
|
||||
0000001547 00000 n
|
||||
trailer << /Size 14 /Root 1 0 R >>
|
||||
startxref
|
||||
1695
|
||||
%%EOF
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""Create an xref section for a simple handmade PDF.
|
||||
|
||||
Not a general purpose tool!!!"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
with open(sys.argv[1], "rb") as infh:
|
||||
pos = 0
|
||||
xref = [(0, 65535, "f")]
|
||||
for spam in infh:
|
||||
text = spam.decode("ascii")
|
||||
if re.match(r"\s*(\d+)\s+(\d+)\s+obj", text):
|
||||
xref.append((pos, 0, "n"))
|
||||
elif text.strip() == "xref":
|
||||
startxref = pos
|
||||
pos = infh.tell()
|
||||
print("xref")
|
||||
print("0", len(xref))
|
||||
for x in xref:
|
||||
print("%010d %05d %s " % x)
|
||||
print("trailer << /Size %d /Root 1 0 R >>" % len(xref))
|
||||
print("startxref")
|
||||
print(startxref)
|
||||
print("%%EOF")
|
||||
Reference in New Issue
Block a user