Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • pesco/pdf
  • andrea/pdf
  • letitiali/pdf
  • denleylam/pdf
  • xentrac/pdf
5 results
Show changes
Showing
with 1396 additions and 0 deletions
File added
File added
File added
#!/bin/sh
cd "$(dirname "$0")/.."
result=0 # success
r=0
echo
for f in test/valid/*.pdf
do
./pdf -s "$f" >/dev/null # suppress stdout but not error messages
x=$?
if [ $x -eq 0 ]
then
echo "ok: $f"
else
echo "FAIL (exit $x): $f"
r=1
fi
done
result=$((result + r))
r=0
echo
for txt in test/valid/*.txt
do
f="$(dirname "$txt")/$(basename "$txt" .txt).pdf"
out="$txt.out"
./pdf -x "$out" "$f" >/dev/null # suppress stdout but not errors
x=$?
if [ $x -eq 0 ] && diff -u "$txt" "$out"
then
echo "text ok: $f"
rm -f "$out"
else
echo "TEXT FAIL: $f"
r=4
fi
done
result=$((result + r))
r=0
echo
for f in test/invalid/*.pdf
do
./pdf -sq "$f" # suppress stdout and error messages
x=$?
if [ $x -eq 1 ] # plain parse failure
then
echo "ok: $f"
else
echo "FAIL (exit $x): $f"
r=2
fi
done
result=$((result + r))
echo
exit $result
Let's LZW-encode the following by hand and include a clear code. Fun!
00000000: 4254 0a20 2020 202f 4631 2032 3420 5466 BT. /F1 24 Tf
00000010: 0a20 2020 2031 3030 2031 3030 2054 640a . 100 100 Td.
00000020: 2020 2020 2028 4865 6c6c 6f20 576f 726c (Hello Worl
00000030: 6429 2054 6a0a 4554 d) Tj.ET
Encoding:
input output binary new code
100 100000000 (clear)
42 42 001000010 102 = 42 54
54 54 001010100 103 = 54 0a
0a 0a 000001010 104 = 0a 20
20 20 000100000 105 = 20 20
20 20 105 100000101 106 = 20 20 20
20 20 000100000 107 = 20 2f
2f 2f 000101111 108 = 2f 46
46 46 001000110 109 = 46 31
31 31 000110001 10a = 31 20
20 20 000100000 10b = 20 32
32 32 000110010 10c = 32 34
34 34 000110100 10d = 34 20
20 20 000100000 10e = 20 54
54 54 001010100 10f = 54 66
66 66 001100110 110 = 66 0a
0a 20 104 100000100 111 = 0a 20 20
20 20 20 106 100000110 112 = 20 20 20 31
31 31 000110001 113 = 31 30
30 30 000110000 114 = 30 30
30 30 000110000 115 = 30 20
20 20 000100000 116 = 20 31
31 30 113 100010011 117 = 31 30 30
30 20 115 100010101 118 = 30 20 54
54 54 001010100 119 = 54 64
64 64 001100100 11a = 64 0a
0a 20 20 111 100010001 11b = 0a 20 20 20
20 20 20 106 100000110 11c = 20 20 20 28
28 28 000101000 11d = 28 48
48 48 001001000 11e = 48 65
65 65 001100101 11f = 65 6c
6c 6c 001101100 120 = 6c 6c
6c 6c 001101100 121 = 6c 6f
6f 6f 001101111 122 = 6f 20
20 20 000100000 123 = 20 57
57 57 001010111 124 = 57 6f
6f 6f 001101111 125 = 6f 72
72 72 001110010 126 = 72 6c
6c 6c 001101100 127 = 6c 64
64 64 001100100 128 = 64 29
29 29 000101001 129 = 29 20
100 100000000 (clear)
20 20 000100000 102 = 20 54
54 54 001010100 103 = 54 6a
6a 6a 001101010 104 = 6a 0a
0a 0a 000001010 105 = 0a 45
45 45 001000101 106 = 45 54
54 54 001010100
101 100000001 (eod)
Max code length is 9 bit, so all codes are 9 bits long and EarlyChange does
not matter.
Total output: 49 codes = 49 * 9 = 441 bits = 56 bytes - 7 bits padding.
output bit stream (MSB):
100000000 001000010 001010100 000001010 000100000 100000101 000100000 000101111
001000110 000110001 000100000 000110010 000110100 000100000 001010100 001100110
100000100 100000110 000110001 000110000 000110000 000100000 100010011 100010101
001010100 001100100 100010001 100000110 000101000 001001000 001100101 001101100
001101100 001101111 000100000 001010111 001101111 001110010 001101100 001100100
000101001 100000000 000100000 001010100 001101010 000001010 001000101 001010100
100000001
output byte steam (MSB):
10000000 00010000 10001010 10000000 10100001 00000100 00010100 01000000 00101111
80 10 8A 80 A1 04 14 40 2F
00100011 00001100 01000100 00000011 00100001 10100000 10000000 10101000 01100110
23 0C 44 03 21 A0 80 A8 66
10000010 01000001 10000110 00100011 00000001 10000000 10000010 00100111 00010101
82 41 86 23 01 80 82 27 15
00101010 00011001 00100010 00110000 01100001 01000001 00100000 11001010 01101100
2A 19 22 30 61 41 20 CA 6C
00110110 00011011 11000100 00000101 01110011 01111001 11001000 11011000 01100100
36 1B C4 05 73 79 C8 D8 64
00010100 11000000 00000100 00000101 01000011 01010000 00101000 10001010 01010100
14 C0 04 05 43 50 28 8A 54
10000000 10000000
80 80
copy & paste into xxd -r -p:
80 10 8A 80 A1 04 14 40 2F 23 0C 44 03 21 A0 80 A8 66 82 41 86 23 01 80 82 27 15
2A 19 22 30 61 41 20 CA 6C 36 1B C4 05 73 79 C8 D8 64 14 C0 04 05 43 50 28 8A 54
80 80
--
output example from the spec:
256 45 258 258 65 259 66 257
100 02d 102 102 041 103 042 101
100000000 000101101 100000010 100000010 001000001 100000011 001000010 100000001
10000000 00001011 01100000 01010000 00100010 00001100 00001100 10000101 00000001
80 0b 60 50 22 0c 0c 85 01
Let's LZW-encode the following by hand and include a double clear code. Fun!
00000000: 4254 0a20 2020 202f 4631 2032 3420 5466 BT. /F1 24 Tf
00000010: 0a20 2020 2031 3030 2031 3030 2054 640a . 100 100 Td.
00000020: 2020 2020 2028 4865 6c6c 6f20 576f 726c (Hello Worl
00000030: 6429 2054 6a0a 4554 d) Tj.ET
Encoding:
input output binary new code
100 100000000 (clear)
100 100000000 (clear)
42 42 001000010 102 = 42 54
54 54 001010100 103 = 54 0a
0a 0a 000001010 104 = 0a 20
20 20 000100000 105 = 20 20
20 20 105 100000101 106 = 20 20 20
20 20 000100000 107 = 20 2f
2f 2f 000101111 108 = 2f 46
46 46 001000110 109 = 46 31
31 31 000110001 10a = 31 20
20 20 000100000 10b = 20 32
32 32 000110010 10c = 32 34
34 34 000110100 10d = 34 20
20 20 000100000 10e = 20 54
54 54 001010100 10f = 54 66
66 66 001100110 110 = 66 0a
0a 20 104 100000100 111 = 0a 20 20
20 20 20 106 100000110 112 = 20 20 20 31
31 31 000110001 113 = 31 30
30 30 000110000 114 = 30 30
30 30 000110000 115 = 30 20
20 20 000100000 116 = 20 31
31 30 113 100010011 117 = 31 30 30
30 20 115 100010101 118 = 30 20 54
54 54 001010100 119 = 54 64
64 64 001100100 11a = 64 0a
0a 20 20 111 100010001 11b = 0a 20 20 20
20 20 20 106 100000110 11c = 20 20 20 28
28 28 000101000 11d = 28 48
48 48 001001000 11e = 48 65
65 65 001100101 11f = 65 6c
6c 6c 001101100 120 = 6c 6c
6c 6c 001101100 121 = 6c 6f
6f 6f 001101111 122 = 6f 20
20 20 000100000 123 = 20 57
57 57 001010111 124 = 57 6f
6f 6f 001101111 125 = 6f 72
72 72 001110010 126 = 72 6c
6c 6c 001101100 127 = 6c 64
64 64 001100100 128 = 64 29
29 29 000101001 129 = 29 20
100 100000000 (clear)
20 20 000100000 102 = 20 54
54 54 001010100 103 = 54 6a
6a 6a 001101010 104 = 6a 0a
0a 0a 000001010 105 = 0a 45
45 45 001000101 106 = 45 54
54 54 001010100
101 100000001 (eod)
Max code length is 9 bit, so all codes are 9 bits long and EarlyChange does
not matter.
Total output: 50 codes = 50 * 9 = 450 bits = 57 bytes - 6 bits padding.
output bit stream (MSB):
100000000 100000000 001000010 001010100 000001010 000100000 100000101 000100000
000101111 001000110 000110001 000100000 000110010 000110100 000100000 001010100
001100110 100000100 100000110 000110001 000110000 000110000 000100000 100010011
100010101 001010100 001100100 100010001 100000110 000101000 001001000 001100101
001101100 001101100 001101111 000100000 001010111 001101111 001110010 001101100
001100100 000101001 100000000 000100000 001010100 001101010 000001010 001000101
001010100 100000001
output byte steam (MSB):
10000000 01000000 00001000 01000101 01000000 01010000 10000010 00001010 00100000
80 40 08 45 40 50 82 0A 20
00010111 10010001 10000110 00100010 00000001 10010000 11010000 01000000 01010100
17 91 86 22 01 90 D0 40 54
00110011 01000001 00100000 11000011 00010001 10000000 11000000 01000001 00010011
33 41 20 C3 11 80 C0 41 13
10001010 10010101 00001100 10010001 00011000 00110000 10100000 10010000 01100101
8A 95 0C 91 18 30 A0 90 65
00110110 00011011 00001101 11100010 00000010 10111001 10111100 11100100 01101100
36 1B 0D E2 02 B9 BC E4 6C
00110010 00001010 01100000 00000010 00000010 10100001 10101000 00010100 01000101
32 0A 60 02 02 A1 A8 14 45
00101010 01000000 01000000
2A 40 40
copy & paste into xxd -r -p:
80 40 08 45 40 50 82 0A 20 17 91 86 22 01 90 D0 40 54 33 41 20 C3 11 80 C0 41 13
8A 95 0C 91 18 30 A0 90 65 36 1B 0D E2 02 B9 BC E4 6C 32 0A 60 02 02 A1 A8 14 45
2A 40 40
--
output example from the spec:
256 45 258 258 65 259 66 257
100 02d 102 102 041 103 042 101
100000000 000101101 100000010 100000010 001000001 100000011 001000010 100000001
10000000 00001011 01100000 01010000 00100010 00001100 00001100 10000101 00000001
80 0b 60 50 22 0c 0c 85 01
Let's LZW-encode the following by hand. Fun!
00000000: 4254 0a20 2020 202f 4631 2032 3420 5466 BT. /F1 24 Tf
00000010: 0a20 2020 2031 3030 2031 3030 2054 640a . 100 100 Td.
00000020: 2020 2020 2028 4865 6c6c 6f20 576f 726c (Hello Worl
00000030: 6429 2054 6a0a 4554 d) Tj.ET
Encoding:
input output binary new code
100 100000000 (clear)
42 42 001000010 102 = 42 54
54 54 001010100 103 = 54 0a
0a 0a 000001010 104 = 0a 20
20 20 000100000 105 = 20 20
20 20 105 100000101 106 = 20 20 20
20 20 000100000 107 = 20 2f
2f 2f 000101111 108 = 2f 46
46 46 001000110 109 = 46 31
31 31 000110001 10a = 31 20
20 20 000100000 10b = 20 32
32 32 000110010 10c = 32 34
34 34 000110100 10d = 34 20
20 20 000100000 10e = 20 54
54 54 001010100 10f = 54 66
66 66 001100110 110 = 66 0a
0a 20 104 100000100 111 = 0a 20 20
20 20 20 106 100000110 112 = 20 20 20 31
31 31 000110001 113 = 31 30
30 30 000110000 114 = 30 30
30 30 000110000 115 = 30 20
20 20 000100000 116 = 20 31
31 30 113 100010011 117 = 31 30 30
30 20 115 100010101 118 = 30 20 54
54 54 001010100 119 = 54 64
64 64 001100100 11a = 64 0a
0a 20 20 111 100010001 11b = 0a 20 20 20
20 20 20 106 100000110 11c = 20 20 20 28
28 28 000101000 11d = 28 48
48 48 001001000 11e = 48 65
65 65 001100101 11f = 65 6c
6c 6c 001101100 120 = 6c 6c
6c 6c 001101100 121 = 6c 6f
6f 6f 001101111 122 = 6f 20
20 20 000100000 123 = 20 57
57 57 001010111 124 = 57 6f
6f 6f 001101111 125 = 6f 72
72 72 001110010 126 = 72 6c
6c 6c 001101100 127 = 6c 64
64 64 001100100 128 = 64 29
29 29 000101001 129 = 29 20
20 54 10e 100001110 12a = 20 54 6a
6a 6a 001101010 12b = 6a 0a
0a 0a 000001010 12c = 0a 45
45 45 001000101 12d = 45 54
54 54 001010100
101 100000001 (eod)
Max code length is 9 bit, so all codes are 9 bits long and EarlyChange does
not matter.
Total output: 47 codes = 47 * 9 = 423 bits = 53 bytes - 1 bit padding.
output bit stream (MSB):
100000000 001000010 001010100 000001010 000100000 100000101 000100000 000101111
001000110 000110001 000100000 000110010 000110100 000100000 001010100 001100110
100000100 100000110 000110001 000110000 000110000 000100000 100010011 100010101
001010100 001100100 100010001 100000110 000101000 001001000 001100101 001101100
001101100 001101111 000100000 001010111 001101111 001110010 001101100 001100100
000101001 100001110 001101010 000001010 001000101 001010100 100000001
output byte steam (MSB):
10000000 00010000 10001010 10000000 10100001 00000100 00010100 01000000 00101111
80 10 8A 80 A1 04 14 40 2F
00100011 00001100 01000100 00000011 00100001 10100000 10000000 10101000 01100110
23 0C 44 03 21 A0 80 A8 66
10000010 01000001 10000110 00100011 00000001 10000000 10000010 00100111 00010101
82 41 86 23 01 80 82 27 15
00101010 00011001 00100010 00110000 01100001 01000001 00100000 11001010 01101100
2A 19 22 30 61 41 20 CA 6C
00110110 00011011 11000100 00000101 01110011 01111001 11001000 11011000 01100100
36 1B C4 05 73 79 C8 D8 64
00010100 11000011 10001101 01000000 10100010 00101001 01010010 00000010
14 C3 8D 40 A2 29 52 02
copy & paste into xxd -r -p:
80 10 8A 80 A1 04 14 40 2F 23 0C 44 03 21 A0 80 A8 66 82 41 86 23 01 80 82 27 15
2A 19 22 30 61 41 20 CA 6C 36 1B C4 05 73 79 C8 D8 64 14 C3 8D 40 A2 29 52 02
--
output example from the spec:
256 45 258 258 65 259 66 257
100 02d 102 102 041 103 042 101
100000000 000101101 100000010 100000010 001000001 100000011 001000010 100000001
10000000 00001011 01100000 01010000 00100010 00001100 00001100 10000101 00000001
80 0b 60 50 22 0c 0c 85 01
File added
File added
File added
File added
File added
File added
File added
File added
Hello World
\ No newline at end of file
File added
Hello World
\ No newline at end of file
File added
File added