/*! * Sythos Barcode Suite * * MIT License * * Copyright (c) 2026 Sythos * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * SPDX-License-Identifier: MIT * * Original work. No code from any other barcode implementation. */ /** PDF417 symbol-character pattern table. @module pdf417/tables */ export const PDF417_CLUSTER_NUMBERS = Object.freeze([0, 3, 6]); export const PDF417_CODEWORDS_PER_CLUSTER = 929; // Transcribed from the normative AIM USS PDF417 specification, Appendix H, // Table H1 (Bar-Space Sequence Table), from a publicly accessible copy hosted // at https://expresscorp.com/wp-content/uploads/2023/02/USS-PDF-417.pdf. // ISO/IEC 15438:2015 is the current ISO specification for PDF417. // Each eight-digit sequence is ordered bar, space, bar, space, bar, space, // bar, space and is indexed by its codeword value from 0 through 928. const WIDTH_SEQUENCES = Object.freeze([ '3111113641111144511111523111123541111243511112512111132631111334211114251111151621111524111116152111213631112144' + '4111215221112235311122434111225111112326211123341111242511113136211131443111315211113235211132433111325111113334' + '2111334211114144211141521111424321114251111151525111611131121135411211435112115121121226311212344112124221121325' + '3112133311121416211214243112143211121515211215231112161421122135311221434112215111122226211222343112224211122325' + '2112233331122341111224242112243211123135211231433112315111123234211232421112333321123341111241432112415111124242' + '1112434121131126311311344113114221131225311312334113124111131316211313243113133211131415211314231113151411131613' + '1113212621132134311321421113222521132233311322411113232421132332111324231113252211133134211331421113323321133241' + '1113333211134142211411253114113341141141111412162114122431141232111413152114132331141331111414142114142211141513' + '2114152111142125211421333114214111142224211422321114232321142331111424221114252121143141111433311115111621151124' + '3115113211151215211512233115123111151314211513221115141321151421111515121115212411152223111523221116111531161131' + '2116122221161321111615113211113542111143521111512211122632111234421112422211132532111333421113411211141622111424' + '1211151522112135321121434211215112112226221122343211224212112325221123331211242412112523121131352211314332113151' + '1211323422113242121133331211343212114143221141511211424212115151312111264121113451211142312112254121123351211241' + '2121131631211324412113322121141531211423412114312121151431211522221211263212113442121142212121262212122532121233' + '4212124121212225312122334121224111212316121214152212142332121431112124152121242311212514121221262212213432122142' + '1121312612122225221222333212224111213225212132333121324111213324121224231121342312123134221231421121413412123233' + '2212324111214233212142411121433212124142112151421212424111215241312211254122113351221141212212163122122441221232' + '2122131531221323412213312122141431221422212215132122161222131125321311334213114121222125221312243213123211222216' + '1213131531222232321313311122231512131414221314221122241421222422221315211213161212132125221321333213214111223125' + '1213222422132232112232242122323222132331112233231213242212132521121331332213314111224133121332321122423212133331' + '1122433111225141212311163123112441231132212312153123122341231231212313143123132221231413312314212123151221231611' + '1214111622141124321411321123211612141215221412233214123111232215212322233123223111232314121414132214142111232413' + '2123242111232512121421242214213211233124121422232214223111233223212332311123332212142421112334211123413211234231' + '2124111531241123412411312124121431241222212413133124132121241412212415111215111522151123321511311124211512151214' + '2215122211242214212422222215132111242313121514121124241212151511121521231124312311243222112433213125112231251221' + '2125141122161122121612131125221311252312112524112311112633111134431111422311122533111233131113162311132433111332' + '1311141523111423131115141311161313112126231121343311214213112225231122333311224113112324231123321311242313112522' + '1311313423113142131132332311324113113332131141421311424132211125422111335221114122211216322112244221123222211315' + '3221132342211331222114143221142222211513322115212312112533121133431211412221212523121224331212321221221613121315' + '3221223233121331122123152221232323121422122124141312151312212513131221252312213333122141122131251312222432213141' + '1221322422213232231223311221332313122422122134221312313323123141122141331312323212214232131233311312414112215141' + '3131111641311124513111323131121541311223513112313131131441311322313114134131142131311512222211163222112442221132' + '2131211622221215413121324222123121312215313122234131223121312314222214133222142121312413313124212222161113131116' + '2313112433131132122221161313121523131223331312311131311612222215222222233222223111313215213132233131323123131421' + '1131331412222413222224211131341313131611131321242313213212223124131322232313223111314124122232232222323111314223' + '2131423113132421122234211313313212224132131332311131513212224231313211154132112351321131313212144132122231321313' + '4132132131321412313215112223111532231123422311312132211522231214413221312132221431322222322313212132231322231412' + '2132241222231511213225111314111523141123331411311223211513141214231412221132311512232214222322222314132111323214' + '2132322213141412113233131223241213141511122325111314212323142131122331231314222211324123122332221314232111324222' + '1223332113143131113251313133111441331122313312134133122131331312313314112224111432241122213321142224121332241221' + '2133221331332221213323122224141121332411131511142315112212242114131512132315122111333114122422132224222111333213' + '2133322113151411113333121224241111333411122431221133412211334221413411213134131132251121222512122225131113161113' + '1225211311343113131613111225231124111125141112162411122414111315241113233411133114111414241114221411151324111521' + '1411212524112133341121411411222424112232141123232411233114112422141125211411313324113141141132321411333114114141' + '2321111633211124432111322321121533211223232113143321132223211413332114212321151214121116241211243412113213212116' + '1412121533212132341212311321221523212223332122311321231414121413241214211321241323212421141216111412212424122132' + '1321312414122223241222311321322323213231132133221412242114123132132141321412323113214231323111154231112352311131' + '3231121442311222323113134231132132311412323115112322111533221123223121152322121433221222223122143231222233221321' + '2231231323221412223124122322151122312511141311152413112313222115141312143322213112313115132222142322222224131321' + '1231321422313222141314121231331313222412141315111322251114132123241321311322312314132222123141231322322214132321' + '1231422213223321141331311322413112315131414111145141112241411213514112214141131241411411323211144232112231412114' + '4141212242321221314122134141222131412312323214113141241123231114332311222232211423231213332312212141311422322213' + '3232222121413213314132212323141121413312223224112141341114141114241411221323211414141213241412211232311413232213' + '2323222111414114123232132232322114141411114142132141422113232411114143121414212213233122141422211232412213233221' + '1141512212324221114152214142111351421121414212124142131132331113423311213142211341422121314222123233131131422311' + '2324111333241121223321132324121221423113223322122324131121423212223323112142331114151113241511211324211323242121' + '1233311313242212141513111142411312333212132423111142421212333311114243111324312111425121414312113143211231432211' + '2234211221433112214332111325211212343112114341121143421115111116151112152511122315111314151114131511151215112124' + '1511222315112322151124211511313215113231242111152421121434211222242113133421132124211412242115111512111525121123' + '1421211524212123251212221421221424212222142123132421232114212412151215111421251115122123251221311421312324213131' + '1421322215122321142133211512313114214131333111143331121333311312333114112422111423312114333121223422122123312213' + '3331222123312312242214112331241115131114142221141513121325131221133131141422221315131312133132131422231215131411' + '1331331214222411151321221422312215132221133141221422322113314221424111134241121242411311333211133241211342412121' + '3241221233321311324123112423111334231121233221133332212122413113233222122423131122413212233223112241331115141113' + '2514112114232113242321211332311314232212151413111241411313323212142323111241421213323311151421211423312113324121' + '1241512151511112515112114242111241512112424212114151221133331112324221123333121131513112324222113151321124241112' + '2333211224241211224231122333221121514112', '5111112561111133411112165111122461111232411113155111132361111331411114145111142241111513511115214111161241112125' + '5111213361112141311122164111222451112232311123154111232351112331311124144111242231112513411125213111261231113125' + '4111313351113141211132163111322441113232211133153111332341113331211134143111342221113513311135212111361221114125' + '3111413341114141111142162111422431114232111143152111432331114331111144142111442211114513211145211111512521115133' + '3111514111115224211152321111532321115331111154221111613321116141111162321111633141121116511211246112113241121215' + '5112122361121231411213145112132241121413511214214112151241121611311221164112212451122132311222154112222351122231' + '3112231441122322311224134112242131122512311226112112311631123124411231322112321531123223411232312112331431123322' + '2112341331123421211235122112361111124116211241243112413211124215211242233112423111124314211243221112441321124421' + '1112451211125124211251321112522321125231111253221112542111126132111262314113111551131123611311314113121451131222' + '4113131351131321411314124113151131132115411321235113213131132214411322223113231341132321311324123113251121133115' + '3113312341133131211332143113322221133313311333212113341221133511111341152113412331134131111342142113422211134313' + '2113432111134412111345111113512321135131111352221113532111136131411411145114112241141213511412214114131241141411' + '3114211441142122311422134114222131142312311424112114311431143122211432133114322121143312211434111114411421144122' + '1114421321144221111443121114441111145122111452214115111351151121411512124115131131152113411521213115221231152311' + '2115311331153121211532122115331111154113211541211115421211154311411611124116121131162112311622112116311221163211' + '4211111652111124621111324211121552111223621112314211131452111322421114135211142142111512421116113211211642112124' + '5211213232112215421122235211223132112314421123223211241342112421321125123211261122113116321131244211313222113215' + '3211322342113231221133143211332222113413321134212211351222113611121141162211412432114132121142152211422332114231' + '1211431422114322121144132211442112114512121151242211513212115223221152311211532212115421121161321211623151211115' + '6121112311211164512112146121122211211263512113136121132111211362512114125121151142121115521211236212113141212115' + '4212121461212131412122145121222252121321412123134212141241212412421215114121251132122115421221235212213131213115' + '3212221442122222312132144121322242122321312133133212241231213412321225113121351122123115321231234212313121214115' + '2212321432123222212142143121422232123321212143132212341221214412221235112121451112124115221241233212413111215115' + '1212421422124222112152142121522222124321112153131212441211215412121245111212512322125131112161231212522211216222' + '1212532111216321121261315122111461221122112211635122121361221221112212625122131211221361512214114213111452131122' + '4122211442131213521312214122221351222221412223124213141141222411321321144213212231223114321322134213222131223213' + '4122322131223312321324113122341122133114321331222122411422133213321332212122421331224221212243122213341121224411' + '1213411422134122112251141213421322134221112252132122522111225312121344111122541112135122112261221213522111226221' + '5123111361231121112311625123121211231261512313114214111352141121412321135123212141232212421413114123231132142113' + '4214212131233113321422123123321232142311312333112214311332143121212341133123412121234212221433112123431112144113' + '2214412111235113121442121123521212144311112353111214512111236121512411121124116151241211421511124124211242151211' + '4124221132152112312431123215221131243211221531122124411222153211212442111215411211245112121542111124521151251111' + '4216111141252111321621113125311122163111212541114311111553111123631111314311121453111222431113135311132143111412' + '4311151133112115431121235311213133112214431122223311231343112321331124123311251123113115331131234311313123113214' + '3311322223113313331133212311341223113511131141152311412333114131131142142311422213114313231143211311441213114511' + '1311512323115131131152221311532113116131522111146221112212211163522112136221122112211262522113121221136152211411' + '4312111453121122422121144312121353121221422122135221222142212312431214114221241133122114431221223221311433122213' + '4312222132213213422132213221331233122411322134112312311433123122222141142312321333123221222142133221422122214312' + '2312341122214411131241142312412212215114131242132312422112215213222152211221531213124411122154111312512212216122' + '1312522112216221613111131131115421311162613112121131125321311261613113111131135211311451522211136222112112221162' + '5131211361312121113121621222126151312212522213111131226151312311431311135313112142222113431312124131311351313121' + '4313131141313212422223114131331133132113431321213222311333132212313141133222321233132311313142123222331131314311' + '2313311333133121222241132313321221315113222242122313331121315212222243112131531113134113231341211222511313134212' + '1131611312225212131343111131621212225311113163111313512112226121613211121132115321321161613212111132125211321351' + '5223111212231161513221125223121111322161513222114314111242232112431412114132311242232211413232113314211232233112' + '3314221131324112322332113132421123143112222341122314321121325112222342112132521113144112122351121314421111326112' + '1223521111326211613311111133115211331251522411115133211143151111422421114133311133152111322431113133411123153111' + '2224411121335111131541111224511111336111113411514411111454111122441112135411122144111312441114113411211444112122' + '3411221344112221341123123411241124113114341131222411321334113221241133122411341114114114241141221411421324114221' + '1411431214114411141151221411522153211113632111211321116253211212132112615321131144121113541211214321211344121212' + '4321221244121311432123113412211344122121332131133412221233213212341223113321331124123113341231212321411324123212' + '2321421224123311232143111412411324124121132151131412421213215212141243111321531114125121132161216231111212311153' + '2231116162311211123112521231135153221112132211615231211253221211123121615231221144131112432221124413121142313112' + '4322221142313211341321123322311234132211323141123322321132314211241331122322411224133211223151122322421122315211' + '1413411213225112141342111231611213225211123162111141114421411152114112432141125111411342114114416232111112321152' + '6141211111412152123212511141225153231111523221115141311144141111432321114232311141414111341421113323311132324111' + '3141511124143111232341112232511121416111141441111323511112326111114211432142115111421242114213411233115111422151' + '1143114211431241114411414511111345111212451113113511211345112121351122123511231125113113351131212511321225113311' + '1511411325114121151142121511431115115121542111121421116154211211451211124421211245121211442122113512211234213112' + '3512221134213211251231122421411225123211242142111512411214215112151242111421521163311111133111521331125154221111' + '5331211145131111442221114331311135132111342231113331411125133111242241112331511115134111142251111331611112411143' + '2241115112411242124113411332115112412151115111342151114211511233215112411151133211511431124211421151214212421241' + '1151224111521133215211411152123211521331124311411152214111531132115312311154113136112112361122112611311226113211' + '1611411216114211452121113612211135213111261231112521411116124111152151111431115113411142134112411251113322511141' + '1251123212511331134211411251214111611124216111321161122321611231116113221161142112521132116121321252123111612231' + '1162112321621131116212221162132112531131116221311163112211631221144111411351113213511231126111232261113112611222' + '1261132113521131126121311262112212621221', '2111115531111163111112462111125431111262111113452111135331111361111114442111145211111543611121141111215521112163' + '6111221311112254211122626111231211112353211123616111241111112452511131146111312211113163511132136111322111113262' + '5111331211113361511134114111411451114122411142135111422141114312411144113111511441115122311152134111522131115312' + '3111541121116114311161222111621331116221211163121112114621121154311211621112124521121253311212611112134421121352' + '1112144321121451111215426112211311122154211221626112221211122253211222616112231111122352111224515112311361123121' + '1112316251123212111232615112331141124113511241214112421241124311311251134112512131125212311253112112611331126121' + '2112621221126311111311452113115331131161111312442113125211131343211313511113144211131541611321121113215321132161' + '6113221111132252111323515113311211133161511332114113411241134211311351123113521121136112211362111114114421141152' + '1114124321141251111413421114144161142111111421521114225151143111411441113114511111151143211511511115124211151341' + '1115215111161142111612411211114622111154321111621211124522111253321112611211134422111352121114432211145112111542' + '6211211312112154221121626211221212112253221122616211231112112352121124515211311362113121121131625211321212113261' + '5211331142114113521141214211421242114311321151134211512132115212321153112211611332116121221162122211631121211145' + '3121115341211161112112362121124431211252112113352121134331211351112114342121144211211533212115411121163212121145' + '2212115332121161112121451212124422121252112122442121225222121351112123431212144211212442121215411121254162122112' + '1212215322122161612131126212221111213153121222526121321111213252121223511121335152123112121231615121411252123211' + '1121416151214211421241124121511242124211412152113212511231216112321252113121621122126112221262111122113621221144' + '3122115211221235212212433122125111221334212213421122143321221441112215321122163112131144221311521122214412131243' + '2213125111222243212222511122234212131441112224416213211112132152612231111122315212132251112232515213311151224111' + '4213411141225111321351113122611122136111112311352123114331231151112312342123124211231333212313411123143211231531' + '1214114322141151112321431214124211232242121413411123234112142151112331511124113421241142112412332124124111241332' + '1124143112151142112421421215124111242241112511332125114111251232112513311216114111252141112611321126123113111145' + '2311115333111161131112442311125213111343231113511311144213111541631121121311215323112161631122111311225213112351' + '5311311213113161531132114311411243114211331151123311521123116112231162111221113622211144322111521221123522211243' + '3221125112211334222113421221143322211441122115321221163113121144231211521221214413121243231212511221224322212251' + '1221234213121441122124416312211113122152622131111221315213122251122132515312311152214111431241114221511133125111' + '3221611123126111213111353131114341311151113112262131123431311242113113252131133331311341113114242131143211311523' + '2131153111311622122211352222114332221151113121351222123422221242113122342131224222221341113123331222143211312432' + '1222153111312531131311432313115112222143131312421131314312222242131313411131324212222341113133411313215112223151' + '1131415111321126213211343132114211321225213212333132124111321324213213321132142321321431113215221132162112231134' + '2223114211322134122312332223124111322233213222411132233212231431113224311314114212232142131412411132314212232241' + '1132324111331125213311333133114111331224213312321133132321331331113314221133152112241133222411411133213312241232' + '1133223212241331113323311315114112242141113331411134112421341132113412232134123111341322113414211225113211342132' + '1225123111342231113511232135113111351222113513211226113111352131113611221136122114111144241111521411124324111251' + '1411134214111441141121521411225154113111441141113411511124116111132111352321114333211151132112342321124213211333' + '2321134113211432132115311412114324121151132121431412124213212242141213411321234114122151132131511231112622311134' + '3231114212311225223112333231124112311324223113321231142322311431123115221231162113221134232211421231213413221233' + '2322124112312233132213321231233213221431123124311413114213222142141312411231314213222241123132412141112531411133' + '4141114111411216214112243141123211411315214113233141133111411414214114221141151321411521114116121232112522321133' + '3232114111412125123212242232123211412224214122322232133111412323123214221141242212321521114125211323113323231141' + '1232213313231232114131331232223213231331114132321232233111413331141411411323214112323141114141411142111621421124' + '3142113211421215214212233142123111421314214213221142141321421421114215121142161112331124223311321142212412331223' + '2233123111422223214222311142232212331421114224211324113212332132132412311142313212332231114232311143111521431123' + '3143113111431214214312221143131321431321114314121143151112341123223411311143212312341222114322221234132111432321' + '1325113112342131114331311144111421441122114412132144122111441312114414111235112211442122123512211144222111451113' + '2145112111451212114513111236112111452121151111432511115115111242151113411511215114211134242111421421123324211241' + '1421133214211431151211421421214215121241142122411331112523311133333111411331122423311232133113232331133113311422' + '1331152114221133242211411331213314221232133122321422133113312331151311411422214113313141124111162241112432411132' + '1241121522411223324112311241131422411322124114132241142112411512124116111332112423321132124121241332122323321231' + '1241222322412231124123221332142112412421142311321332213214231231124131321332223112413231215111153151112341511131' + '2151121431511222215113133151132121511412215115111242111522421123324211311151211512421214224212221151221421512222' + '2242132111512313124214121151241212421511115125111333112323331131124221231333122211513123124222221333132111513222' + '1242232111513321142411311333213112423131115141312152111431521122215212133152122121521312215214111243111422431122' + '1152211412431213224312211152221321522221115223121243141111522411133411221243212213341221115231221243222111523221' + '2153111331531121215312122153131112441113224411211153211312441212115322121244131111532311133511211244212111533121' + '2154111221541211124511121154211212451211115422111611114216111241152111332521114115211232152113311612114115212141' + '1431112424311132143112232431123114311322143114211522113214312132152212311431223113411115234111233341113113411214' + '2341122213411313234113211341141213411511143211232432113113412123234121311341222214321321134123211523113114322131' + '1341313122511114325111222251121332511221225113122251141113421114234211221251211422512122234212211251221313421312' + '1251231213421411125124111433112213422122143312211251312213422221125132213161111341611121316112123161131122521113' + '3252112121612113225212122161221222521311216123111343111323431121125221131343121211613113125222121343131111613212' + '1252231111613311143411211343212112523121116141213162111231621211225311122162211222531211216222111344111212532112' + '1344121111623112125322111162321131631111225411112163211113451111125421111163311116211132162112311531112325311131' + '1531122215311321162211311531213114411114244111221441121324411221144113121441141115321122144121221532122114412221' + '2351111333511121235112122351131114421113244211211351211323512121135122121442131113512311153311211442212113513121' + '3261111232611211235211122261211223521211226122111443111213522112144312111261311213522211126132113262111123531111' + '2262211114441111135321111262311116311122163112211541111325411121154112121541131116321121154121212451111224511211' + '1542111214512112154212111451221133611111', ]); function patternFromWidths(sequence) { let pattern = 0; for (let element = 0; element < 8; element++) { const width = sequence.charCodeAt(element) - 48; const dark = (element & 1) === 0; for (let i = 0; i < width; i++) pattern = (pattern << 1) | (dark ? 1 : 0); } return pattern; } /** Return the cluster discriminator for an eight-element bar/space sequence. */ export function pdf417ClusterForWidths(widths) { if (!widths || widths.length !== 8) throw new Error('PDF417: a character requires eight element widths'); return ((widths[0] - widths[2] + widths[4] - widths[6]) % 9 + 9) % 9; } function buildPatternTable() { const tables = WIDTH_SEQUENCES.map((source, tableIndex) => { if (source.length !== PDF417_CODEWORDS_PER_CLUSTER * 8) throw new Error('PDF417: corrupt pattern-table length'); const expectedCluster = PDF417_CLUSTER_NUMBERS[tableIndex]; const table = new Int32Array(PDF417_CODEWORDS_PER_CLUSTER); const seen = new Set(); for (let codeword = 0; codeword < PDF417_CODEWORDS_PER_CLUSTER; codeword++) { const sequence = source.slice(codeword * 8, codeword * 8 + 8); const widths = Array.from(sequence, (digit) => digit.charCodeAt(0) - 48); if (widths.some((width) => width < 1 || width > 6) || widths.reduce((sum, width) => sum + width, 0) !== 17) { throw new Error('PDF417: corrupt pattern-table width'); } if (pdf417ClusterForWidths(widths) !== expectedCluster) throw new Error('PDF417: corrupt pattern-table cluster'); const pattern = patternFromWidths(sequence); if (seen.has(pattern)) throw new Error('PDF417: duplicate pattern in cluster'); seen.add(pattern); table[codeword] = pattern; } return Object.freeze(Array.from(table)); }); return Object.freeze(tables); } /** Pattern table indexed by cluster index (0, 1, 2) and codeword value. */ export const PDF417_PATTERN_TABLE = buildPatternTable(); const PATTERN_TO_CODEWORD = new Map(); for (let index = 0; index < PDF417_PATTERN_TABLE.length; index++) { for (let codeword = 0; codeword < PDF417_CODEWORDS_PER_CLUSTER; codeword++) { PATTERN_TO_CODEWORD.set(PDF417_PATTERN_TABLE[index][codeword], Object.freeze({ codeword, cluster: PDF417_CLUSTER_NUMBERS[index], })); } } /** * Return the 17-bit bar/space pattern for a codeword in a row cluster. * @param {number} codeword * @param {number} cluster Cluster number 0, 3 or 6. * @returns {number} */ export function pdf417PatternForCodeword(codeword, cluster) { if (!Number.isInteger(codeword) || codeword < 0 || codeword >= PDF417_CODEWORDS_PER_CLUSTER) throw new Error('PDF417: codeword must be in 0..928'); const index = PDF417_CLUSTER_NUMBERS.indexOf(cluster); if (index < 0) throw new Error('PDF417: cluster must be 0, 3 or 6'); return PDF417_PATTERN_TABLE[index][codeword]; } /** * Decode an exact 17-bit symbol-character pattern to its codeword and cluster. * @param {number} pattern * @returns {{codeword: number, cluster: number} | null} */ export function pdf417CodewordForPattern(pattern) { const result = PATTERN_TO_CODEWORD.get(pattern); return result ? { ...result } : null; }