Step-by-step codes: read / encode PDF417

Do you like codes? Well, or do not love. In any case, sometimes you need to know how to use them correctly. You can go the long way, as I did last time , but when there is no time, it is easier to use the instructions.


So, let's deal with everything you need to read and / or write PDF417. After all, it’s not always at hand to find a smartphone with a program for reading them. And for the record - and even more so.


Attention, under the cut - 9 images with a total size of 2.79 MB, 6 tables and a few formulas.





Table of contents






01. History of PDF417 and right of use


( Back | Table of Contents | Forward )


PDF417 invented by Symbol Technologies Inc. in 1991, and on September 7, 1993, a US patent was issued for him under the number 5,243,655 (available, for example, here ). In fact, the patent describes not just a coding method, but a complex system for encoding and decoding data ( "System for encoding and decoding data in machine readable graphic form" ). In addition, not all of the recommendations in the patent are currently used.


, PDF417 , .


: ISO/IEC 15438:2015, PDF417, — 198 CHF ( ). , . , , .





02.


( | | )


() PDF417 (. 1) — , . , ( ) . ().


, . PDF417 3 90 , 3 30 .




. 1. PDF417


17 ( ), 4 4 . 1 6 .


x−(x0,…,x7). 3 (), "", "". , t−, ti=xi−1+xi. .


PDF417 . , 0,3,6,…, — 1,4,7,…, — 2,5,8,…. (. 2), .


x−t−:


C=(x0−x2+x4−x6)mod9,
C=(t1−t2+t5−t6)mod9,


mod9— 9.


, 3 , 9 , . : C=(nrmod3)∗3.


PDF417 929 ( 000 928).





03.


( | | )


(. 2):


  • , , (N);
  • N−1, ;
  • Ne;
  • Nr.



. 2. PDF417


, , ( 900, ), d0,d1,….





04.


( | | )


, PDF417 000 928 . , 2 787 .


000 899 .


900 : 928 — (. 1). 900, 901, 902, 913 924, .



##
900(TC)
901- (BC)
902(NC)
903: 912
913-
914: 920
921
922PDF macro
923PDF macro
924-6
925ECI / GLI
926ECI / GLI
927ECI / GLI
928PDF macro

. 1. PDF417. ,


PDF macro PDF417 . , ( ) .


ECI / GLI — Extended Channel Interpretation / Global Label Identifier — , . , ( , GLI 0, ), .





04.a) (TC, Text Compaction Mode)


( | | )


PDF417 ( ). 4 :


  • Alpha ( );
  • Lower case;
  • Mixed;
  • Punctuation.


##Alpha
(ASCII)
Lower case
(ASCII)
Mixed
(ASCII)
Punctuation
(ASCII)
0A (65)a (97)0 (48); (59)
1B (66)b (98)1 (49)< (60)
2C (67)c (99)2 (50)> (62)
3D (68)d (100)3 (51)@ (64)
4E (69)e (101)4 (52)[ (91)
5F (70)f (102)5 (53)\ (92)
6G (71)g (103)6 (54)] (93)
7H (72)h (104)7 (55)_ (95)
8I (73)i (105)8 (56)` (96)
9J (74)j (106)9 (57)~ (126)
10K (75)k (107)& (38)! (33)
11L (76)l (108)CR (13)CR (13)
12M (77)m (109)HT (9)HT (9)
13N (78)n (110), (44), (44)
14O (79)o (111): (58): (58)
15P (80)p (112)# (35)LF (10)
16Q (81)q (113)— (45)— (45)
17R (82)r (114). (46). (46)
18S (83)s (115)$ (36)$ (36)
19T (84)t (116)/ (47)/ (47)
20U (85)u (117)+ (43)" (34)
21V (86)v (118)% (37)| (124)
22W (87)w (119)* (42)* (42)
23X (88)x (120)= (61)( (40)
24Y (89)y (121)^ (94)) (41)
25Z (90)z (122)pl? (63)
26SP (32)SP (32)SP (32){ (123)
27llasll} (125)
28mlmlal' (39)
29pspspsal

. 2. GLI 0


  • al, ll, ml pl — alpha, lower case, mixed punctuation (l = latch);
  • as ps — alpha punctuation (s = shift) .

900 2 :


V=30∗H+L,


V— 900, H— , L— . X1X2.


, , H-, L- 29.


shift- . latch- .





04.b) - (BC, Byte Compaction Mode)


( | | )


900. 256. :


  • 901 ( 6);
  • 924 ( ).

, 6 5 256 900. , 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, (. 3).




. 3. , -


:


924, 001, 620, 089, 074, 846.


6, 6 5 , — . , 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 :


901, 001, 620, 089, 074, 846, 007, 008, 009.


, - 913.





04.c) (NC, Numeric Compaction Mode)


( | | )


10 900. , 0 9. , 44 15 .


902. , 13 . , 3 ( , 2.93) , , (2 ).


900 1 , . 4. , 1 .




. 4. ,





05.


( | | )


. PDF417 2 . , , (. 3).




( )
02 (0)
14 (2)
28 (6)
316 (14)
432 (30)
564 (62)
6128 (126)
7256 (254)
8512 (510)

. 3. PDF417


:


  • , (erasures), " ";
  • , , (errors), " ".

:


e−;
k−;
s−;
Ne=2s+1−.


:


e+2k≤d−2


2 , , , .


Error Correction Capacity, , . , , . , s=0, , :


e+2k≤d−3.


2 , . 2 .


, s=3, 13 , 7 , , (9 2 ..).


- GF(929). .


(. 4).



-
0: 402
41: 1603
161: 3204
321: 8635

. 4.





06.


( | | )


( 03), PDF417.


, , . , , , , , (. 5).




. 5.





07.


( | | )


x-, 17- GitHub


( 02), PDF417 3 (0, 3 6) 929 . 17- , x-. , , , , . 5.



##036
0311111365111112521111155
1411111446111113331111163
2511111524111121611111246
3311112355111122421111254
4411112436111123231111262
5511112514111131511111345
6211113265111132321111353
7311113346111133131111361
8211114254111141411111444
9111115165111142221111452
10211115244111151311111543
11111116155111152161112114
12211121364111161211112155
13311121444111212521112163
14411121525111213361112213
15211122356111214111112254
16311122433111221621112262
17411122514111222461112312
18111123265111223211112353
19211123343111231521112361
20

. 5. 20 x-





08. 8-


( | | )


GLI 0


ASCII 0:127. 128:255 PC 437.



################
0NUL32SP64@96`128Ç160á192└224α
1SOH33!65A97a129ü161í193┴225ß
2STX34"66B98b130é162ó194┬226Γ
3ETX35#67C99c131â163ú195├227π
4EOT36$68D100d132ä164ñ196─228Σ
5ENQ37%69E101e133à165Ñ197┼229σ
6ACK38&70F102f134å166ª198╞230µ
7BEL39'71G103g135ç167º199╟231τ
8BS40(72H104h136ê168¿200╚232Φ
9HT41)73I105i137ë169⌐201╔233Θ
10LF42*74J106j138è170¬202╩234Ω
11VT43+75K107k139ï171½203╦235δ
12FF44,76L108l140î172¼204╠236∞
13CR45-77M109m141ì173¡205═237φ
14SO46.78N110n142Ä174«206╬238ε
15SI47/79O111o143Å175»207╧239∩
16DLE48080P112p144É176░208╨240≡
17DC149181Q113q145æ177▒209╤241±
18DC250282R114r146Æ178▓210╥242≥
19DC351383S115s147ô179│211╙243≤
20DC452484T116t148ö180┤212╘244⌠
21NAK53585U117u149ò181╡213╒245⌡
22SYN54686V118v150û182╢214╓246÷
23ETB55787W119w151ù183╖215╫247≈
24CAN56888X120x152ÿ184╕216╪248°
25EM57989Y121y153Ö185╣217┘249∙
26SUB58:90Z122z154Ü186║218┌250·
27ESC59;91[123{155¢187╗219█251√
28FS60<92\124|156£188╝220▄252ⁿ
29GS61=93]125}157¥189╜221▌253²
30RS62>94^126~158₧190╛222▐254■
31US63?95_127DEL159ƒ191┐223▀255NBSP

. 6. GLI 0, PDF417


GLI 1


ISO 8859-1 ().





09. PDF417,


( | | )


PDF417 .


, , PDF417 - -, x- 81111113 711311121 (18 ) .


, PDF417 (. 6). , - -.




. 6. 0 PDF417





10.


( | | )


. ( 0, 0). , 19 (. 7). , , ( , , 06). , 1 -, 18 - 8 , 27, .


. , .




. 7. ,





11. PDF417


( | | )


, 000 928 (. 8). , , .




. 8.


— 900 : 928. . 8, . , (TC, 04.a).





12.


( | | )


, , 2 :


V=30∗H+L


H30, L— 30.


:


(27)(07) (19)(19) (15)(18) (28)(14) (19)(19) (28)(07) (27)(00) (01)(17) (29)(17) (02)(14) (12)(29) (19)(15) (14)(18) (19)(28) (19)(05) (00)(00) (09)(06) (02)(29)


( . 2):


(ll)https(ml)://(al)H(ll)abr(ps).com(ps)/post(ml)/500962(ps)


(ll), (ml), (al) (ps) 04.a.


:


https://Habr.com/post/500962


, . 8 ( 05).





13.


( | | )


— . .


, . , 3 . , ( ).


, — x−, t−( 02). PDF417 , ( ..), , , — . , .


. , , ( ). .





14.


( | | )


, , .



1.  P -   
2. ,      (900)
3.  N -  ,   ,    P

    4.  N ≥ 13
        5.     (902)
        6.    
        7.  P
        8.    3

    9.  N < 13
        10.  T -    ,  
             .      
              (901, 902, 913, 924)    
              13 .

        11.  T ≥ 5
            12.     (900)
            13.  
            14.  P
            15.   3

        16. T < 5
            17.  B -    , 
                  P.     11
                 4.

            18. B == 1 &   - 
                19.      1  (913)
                20.   
                21.  P
                22.    3

            23. 
                24.     (901  924   
                     ,  04.b)
                25. 
                26.  P
                27.    3





15. ,


( | | )


, PDF417 , . , 3:1( , . 4). , 4:1.


, PDF417 " ", 2 .


:


H=NrY+2Q
W=(17Nc+69)X+2Q



H— ;
W— ;
Nr— ;
Nc— ;
Y— ();
X— ;
Q— ( 2X).





16. () PDF417


( | | )


PDF417 "" ( ), PDF417 (Truncated PDF417, . 9).


:


  • ( , 06);
  • - 1 .

34 15 :


W=(17Nc+35)X+2Q




. 9. PDF417 ( , )


, :


  • , ;
  • - .




17.


( | | )


PDF417






  • + (GitHub)




18.


( | | )


, PDF417. (, , ) , .


, step by step:



, , , ( PDF417).


, , - . , .


!




P.S. , , . "Ctrl / ⌘ + Enter", Ctrl / ⌘, . , . !


All Articles