[{"data":1,"prerenderedAt":1360},["ShallowReactive",2],{"authors":3,"article-2022-04-28-recuperer-les-coordonnees-dans-un-fichier-pdf-avec-pdfjs-dist":331},[4,23,35,48,61,73,85,98,111,124,136,148,161,173,185,197,209,221,233,245,258,270,282,295,307,319],{"id":5,"title":6,"body":7,"description":11,"extension":14,"meta":15,"name":16,"navigation":17,"path":18,"readingTime":19,"seo":20,"stem":21,"__hash__":22},"authors\u002Fauthors\u002Falexandre-guillon.md","Software Engineer",{"type":8,"value":9,"toc":10},"minimark",[],{"title":11,"searchDepth":12,"depth":12,"links":13},"",2,[],"md",{},"Alexandre Guillon",true,"\u002Fauthors\u002Falexandre-guillon",1,{"title":6,"description":11},"authors\u002Falexandre-guillon","4tf48mjyjFNqItOHaulICbrjeCyMag1o6801uHeTz98",{"id":24,"title":6,"body":25,"description":11,"extension":14,"meta":29,"name":30,"navigation":17,"path":31,"readingTime":19,"seo":32,"stem":33,"__hash__":34},"authors\u002Fauthors\u002Falexis-ablain.md",{"type":8,"value":26,"toc":27},[],{"title":11,"searchDepth":12,"depth":12,"links":28},[],{},"Alexis Ablain","\u002Fauthors\u002Falexis-ablain",{"title":6,"description":11},"authors\u002Falexis-ablain","_SIAtB7f-39e5t3GiJof81NP47s6MGo2n4gaHkTy1uQ",{"id":36,"title":37,"body":38,"description":11,"extension":14,"meta":42,"name":43,"navigation":17,"path":44,"readingTime":19,"seo":45,"stem":46,"__hash__":47},"authors\u002Fauthors\u002Faxel-shaita.md","Engineering Manager",{"type":8,"value":39,"toc":40},[],{"title":11,"searchDepth":12,"depth":12,"links":41},[],{},"Axel Shaïta","\u002Fauthors\u002Faxel-shaita",{"title":37,"description":11},"authors\u002Faxel-shaita","fK0argUhsBkWLjpTAhY13oYLVzQthcEYkCEdtHWmIgE",{"id":49,"title":50,"body":51,"description":11,"extension":14,"meta":55,"name":56,"navigation":17,"path":57,"readingTime":19,"seo":58,"stem":59,"__hash__":60},"authors\u002Fauthors\u002Fbaptiste-faure.md","Head of Talent Acquisition",{"type":8,"value":52,"toc":53},[],{"title":11,"searchDepth":12,"depth":12,"links":54},[],{},"Baptiste Faure","\u002Fauthors\u002Fbaptiste-faure",{"title":50,"description":11},"authors\u002Fbaptiste-faure","ELisToYtcgHmgdVWZkCclTPV6exZtfyXqhpx1jjbJHs",{"id":62,"title":6,"body":63,"description":11,"extension":14,"meta":67,"name":68,"navigation":17,"path":69,"readingTime":19,"seo":70,"stem":71,"__hash__":72},"authors\u002Fauthors\u002Fbenjamin-bouillot.md",{"type":8,"value":64,"toc":65},[],{"title":11,"searchDepth":12,"depth":12,"links":66},[],{},"Benjamin Bouillot","\u002Fauthors\u002Fbenjamin-bouillot",{"title":6,"description":11},"authors\u002Fbenjamin-bouillot","tbhCFZyfTt7ZM5b5YgqQ2nhgnSTl8BweaQQryc87fHo",{"id":74,"title":37,"body":75,"description":11,"extension":14,"meta":79,"name":80,"navigation":17,"path":81,"readingTime":19,"seo":82,"stem":83,"__hash__":84},"authors\u002Fauthors\u002Fcedric-nicoloso.md",{"type":8,"value":76,"toc":77},[],{"title":11,"searchDepth":12,"depth":12,"links":78},[],{},"Cédric Nicoloso","\u002Fauthors\u002Fcedric-nicoloso",{"title":37,"description":11},"authors\u002Fcedric-nicoloso","ibSoh4VZYiWYTuLOnZTedaAfcnvet1Q9H7ogW0LgorY",{"id":86,"title":87,"body":88,"description":11,"extension":14,"meta":92,"name":93,"navigation":17,"path":94,"readingTime":19,"seo":95,"stem":96,"__hash__":97},"authors\u002Fauthors\u002Fdavid-touzet.md","Staff Engineer",{"type":8,"value":89,"toc":90},[],{"title":11,"searchDepth":12,"depth":12,"links":91},[],{},"David Touzet","\u002Fauthors\u002Fdavid-touzet",{"title":87,"description":11},"authors\u002Fdavid-touzet","dHWwnQxb1Ubt-WwXWEODGEo9AFoq1cJUhfg3kdnYSBM",{"id":99,"title":100,"body":101,"description":11,"extension":14,"meta":105,"name":106,"navigation":17,"path":107,"readingTime":19,"seo":108,"stem":109,"__hash__":110},"authors\u002Fauthors\u002Feloise-chizat.md","Data Engineer",{"type":8,"value":102,"toc":103},[],{"title":11,"searchDepth":12,"depth":12,"links":104},[],{},"Eloïse Chizat","\u002Fauthors\u002Feloise-chizat",{"title":100,"description":11},"authors\u002Feloise-chizat","Utd72Vm9qT4hh2ZbFi6a2_nXw5Wb494Ed_HL1ra5yw8",{"id":112,"title":113,"body":114,"description":11,"extension":14,"meta":118,"name":119,"navigation":17,"path":120,"readingTime":19,"seo":121,"stem":122,"__hash__":123},"authors\u002Fauthors\u002Femmanuel-auclair.md","Staff engineer",{"type":8,"value":115,"toc":116},[],{"title":11,"searchDepth":12,"depth":12,"links":117},[],{},"Emmanuel Auclair","\u002Fauthors\u002Femmanuel-auclair",{"title":113,"description":11},"authors\u002Femmanuel-auclair","MtsA8THNLEn0dTtYEIQaGwDuf7MjQL55IOeei5gugEg",{"id":125,"title":6,"body":126,"description":11,"extension":14,"meta":130,"name":131,"navigation":17,"path":132,"readingTime":19,"seo":133,"stem":134,"__hash__":135},"authors\u002Fauthors\u002Fhoreb-parraud.md",{"type":8,"value":127,"toc":128},[],{"title":11,"searchDepth":12,"depth":12,"links":129},[],{},"Horeb Parraud","\u002Fauthors\u002Fhoreb-parraud",{"title":6,"description":11},"authors\u002Fhoreb-parraud","ajjsnUX4ohZI-ghMdbb92q_taWDkKXVZSLZXoAeLQtg",{"id":137,"title":37,"body":138,"description":11,"extension":14,"meta":142,"name":143,"navigation":17,"path":144,"readingTime":19,"seo":145,"stem":146,"__hash__":147},"authors\u002Fauthors\u002Fhugo-contreras.md",{"type":8,"value":139,"toc":140},[],{"title":11,"searchDepth":12,"depth":12,"links":141},[],{},"Hugo Contreras","\u002Fauthors\u002Fhugo-contreras",{"title":37,"description":11},"authors\u002Fhugo-contreras","2nc3VMu9ASq9Z6Pwx2-7-Ye991Pww4p-UEDBQFfjF-Q",{"id":149,"title":150,"body":151,"description":11,"extension":14,"meta":155,"name":156,"navigation":17,"path":157,"readingTime":19,"seo":158,"stem":159,"__hash__":160},"authors\u002Fauthors\u002Fjulien-tassin.md","Head of Engineering",{"type":8,"value":152,"toc":153},[],{"title":11,"searchDepth":12,"depth":12,"links":154},[],{},"Julien Tassin","\u002Fauthors\u002Fjulien-tassin",{"title":150,"description":11},"authors\u002Fjulien-tassin","iUIHI7SITje38Jh9X9uvYs4-VsHx4eCdt6hAlyLFG_o",{"id":162,"title":6,"body":163,"description":11,"extension":14,"meta":167,"name":168,"navigation":17,"path":169,"readingTime":19,"seo":170,"stem":171,"__hash__":172},"authors\u002Fauthors\u002Flaurent-renard.md",{"type":8,"value":164,"toc":165},[],{"title":11,"searchDepth":12,"depth":12,"links":166},[],{},"Laurent Renard","\u002Fauthors\u002Flaurent-renard",{"title":6,"description":11},"authors\u002Flaurent-renard","5BP7Ed-pt1SQHjh0UJ1XUrlLTcdlFaDoKBCP4deHq8A",{"id":174,"title":6,"body":175,"description":11,"extension":14,"meta":179,"name":180,"navigation":17,"path":181,"readingTime":19,"seo":182,"stem":183,"__hash__":184},"authors\u002Fauthors\u002Fleo-martin.md",{"type":8,"value":176,"toc":177},[],{"title":11,"searchDepth":12,"depth":12,"links":178},[],{},"Léo Martin","\u002Fauthors\u002Fleo-martin",{"title":6,"description":11},"authors\u002Fleo-martin","eYxCHkRgbGDV7shKdTA9s7Tu0zGV4yDGFoKR5MHQntY",{"id":186,"title":6,"body":187,"description":11,"extension":14,"meta":191,"name":192,"navigation":17,"path":193,"readingTime":19,"seo":194,"stem":195,"__hash__":196},"authors\u002Fauthors\u002Floic-bousquet.md",{"type":8,"value":188,"toc":189},[],{"title":11,"searchDepth":12,"depth":12,"links":190},[],{},"Loïc Bousquet","\u002Fauthors\u002Floic-bousquet",{"title":6,"description":11},"authors\u002Floic-bousquet","ko12qZwiGL8XNjAoy9oWypPkIjr29Pbq7vhdtgldqeQ",{"id":198,"title":6,"body":199,"description":11,"extension":14,"meta":203,"name":204,"navigation":17,"path":205,"readingTime":19,"seo":206,"stem":207,"__hash__":208},"authors\u002Fauthors\u002Floic-poullain.md",{"type":8,"value":200,"toc":201},[],{"title":11,"searchDepth":12,"depth":12,"links":202},[],{},"Loïc Poullain","\u002Fauthors\u002Floic-poullain",{"title":6,"description":11},"authors\u002Floic-poullain","oRIyJhFRTqxy5dLCYQ2OnYZ1DB-gLDUM-85vTSYuTF0",{"id":210,"title":100,"body":211,"description":11,"extension":14,"meta":215,"name":216,"navigation":17,"path":217,"readingTime":19,"seo":218,"stem":219,"__hash__":220},"authors\u002Fauthors\u002Fmaud-lelu.md",{"type":8,"value":212,"toc":213},[],{"title":11,"searchDepth":12,"depth":12,"links":214},[],{},"Maud Lélu","\u002Fauthors\u002Fmaud-lelu",{"title":100,"description":11},"authors\u002Fmaud-lelu","MMbsCKuE41OMHusrl12FIEsI-Trx7l8Nn_ANhvj2_y4",{"id":222,"title":37,"body":223,"description":11,"extension":14,"meta":227,"name":228,"navigation":17,"path":229,"readingTime":19,"seo":230,"stem":231,"__hash__":232},"authors\u002Fauthors\u002Fnicolas-poirier.md",{"type":8,"value":224,"toc":225},[],{"title":11,"searchDepth":12,"depth":12,"links":226},[],{},"Nicolas Poirier","\u002Fauthors\u002Fnicolas-poirier",{"title":37,"description":11},"authors\u002Fnicolas-poirier","dXrJkYo8az4SN_D23aYc3fQ7z8s1dR2a0lt1ogjAjJs",{"id":234,"title":37,"body":235,"description":11,"extension":14,"meta":239,"name":240,"navigation":17,"path":241,"readingTime":19,"seo":242,"stem":243,"__hash__":244},"authors\u002Fauthors\u002Fraphael-sauget.md",{"type":8,"value":236,"toc":237},[],{"title":11,"searchDepth":12,"depth":12,"links":238},[],{},"Raphaël Sauget","\u002Fauthors\u002Fraphael-sauget",{"title":37,"description":11},"authors\u002Fraphael-sauget","Uri9bcq0QDuxRA0PbBoNtu7p_5L3dALu4kzcXVW0xyM",{"id":246,"title":247,"body":248,"description":11,"extension":14,"meta":252,"name":253,"navigation":17,"path":254,"readingTime":19,"seo":255,"stem":256,"__hash__":257},"authors\u002Fauthors\u002Fromain-koenig.md","Co-funder & Head of innovation",{"type":8,"value":249,"toc":250},[],{"title":11,"searchDepth":12,"depth":12,"links":251},[],{},"Romain Koenig","\u002Fauthors\u002Fromain-koenig",{"title":247,"description":11},"authors\u002Fromain-koenig","uyS8--eG2_ezyqRABcJnMJmQKKuSArhPWd14aUvFeEw",{"id":259,"title":37,"body":260,"description":11,"extension":14,"meta":264,"name":265,"navigation":17,"path":266,"readingTime":19,"seo":267,"stem":268,"__hash__":269},"authors\u002Fauthors\u002Fromaric-juniet.md",{"type":8,"value":261,"toc":262},[],{"title":11,"searchDepth":12,"depth":12,"links":263},[],{},"Romaric Juniet","\u002Fauthors\u002Fromaric-juniet",{"title":37,"description":11},"authors\u002Fromaric-juniet","4Zb2artgT-eo-PHLXi3xi4d5t7s6PfhUxeSfXIikSUY",{"id":271,"title":6,"body":272,"description":11,"extension":14,"meta":276,"name":277,"navigation":17,"path":278,"readingTime":19,"seo":279,"stem":280,"__hash__":281},"authors\u002Fauthors\u002Fstanyslas-bres.md",{"type":8,"value":273,"toc":274},[],{"title":11,"searchDepth":12,"depth":12,"links":275},[],{},"Stanyslas Bres","\u002Fauthors\u002Fstanyslas-bres",{"title":6,"description":11},"authors\u002Fstanyslas-bres","Xa0SahETuiN4q1jrmR2ych3moAqcZ2LbU7vSfEt2RuU",{"id":283,"title":284,"body":285,"description":11,"extension":14,"meta":289,"name":290,"navigation":17,"path":291,"readingTime":19,"seo":292,"stem":293,"__hash__":294},"authors\u002Fauthors\u002Ftalent-acquisition.md","Talent Acquisition",{"type":8,"value":286,"toc":287},[],{"title":11,"searchDepth":12,"depth":12,"links":288},[],{},"Équipe Talent Acquisition","\u002Fauthors\u002Ftalent-acquisition",{"description":11},"authors\u002Ftalent-acquisition","doDfE76txftQ4wIiKjJoDmSpyzSKk0tzlgVAp6-opAY",{"id":296,"title":6,"body":297,"description":11,"extension":14,"meta":301,"name":302,"navigation":17,"path":303,"readingTime":19,"seo":304,"stem":305,"__hash__":306},"authors\u002Fauthors\u002Fvictor-borg.md",{"type":8,"value":298,"toc":299},[],{"title":11,"searchDepth":12,"depth":12,"links":300},[],{},"Victor Borg","\u002Fauthors\u002Fvictor-borg",{"title":6,"description":11},"authors\u002Fvictor-borg","-Za-JweoiP6hyclue_WkxMXdRUDTczPGlJf6AZckjUc",{"id":308,"title":6,"body":309,"description":11,"extension":14,"meta":313,"name":314,"navigation":17,"path":315,"readingTime":19,"seo":316,"stem":317,"__hash__":318},"authors\u002Fauthors\u002Fvirgil-roger.md",{"type":8,"value":310,"toc":311},[],{"title":11,"searchDepth":12,"depth":12,"links":312},[],{},"Virgil Roger","\u002Fauthors\u002Fvirgil-roger",{"title":6,"description":11},"authors\u002Fvirgil-roger","DfVFe5j0bCgXeEr381ZYOM5DP4m-pWb93J9-m_muKJ0",{"id":320,"title":6,"body":321,"description":11,"extension":14,"meta":325,"name":326,"navigation":17,"path":327,"readingTime":19,"seo":328,"stem":329,"__hash__":330},"authors\u002Fauthors\u002Fyukan-zhao.md",{"type":8,"value":322,"toc":323},[],{"title":11,"searchDepth":12,"depth":12,"links":324},[],{},"Yukan Zhao","\u002Fauthors\u002Fyukan-zhao",{"title":6,"description":11},"authors\u002Fyukan-zhao","LRPHugtAJnWHsmHxy9_SR5Zas_C5p-GR_uHEs1Fhk_E",{"id":332,"title":333,"author":334,"body":335,"date":1350,"description":1351,"extension":14,"lang":1352,"meta":1353,"navigation":17,"path":1354,"published":17,"readingTime":548,"seo":1355,"stem":1356,"tags":1357,"__hash__":1359},"articles\u002Farticles\u002F2022-04-28-recuperer-les-coordonnees-dans-un-fichier-pdf-avec-pdfjs-dist.md","Récupérer les coordonnées dans un fichier pdf avec pdfjs-dist","david-touzet",{"type":8,"value":336,"toc":1344},[337,342,346,349,359,362,365,370,383,394,418,421,441,444,449,453,456,459,556,559,635,638,1256,1259,1284,1292,1295,1300,1311,1321,1326,1340],[338,339,341],"h2",{"id":340},"contexte","Contexte",[343,344,345],"p",{},"Chez Indy on fait de la compta ",[343,347,348],{},"Presque chaque année, les documents changent (dans notre jargon on parle de millésime) et on doit\nmettre à jour notre générateur de document. Les documents sont mis à disposition par l'État et sont\ndes PDF sans zone de texte clairement définie.",[343,350,352,353],{"align":351},"center","\n  ",[354,355],"img",{"src":356,"alt":357,"style":358},"https:\u002F\u002Fmedia.giphy.com\u002Fmedia\u002FKDRv3QggAjyo\u002Fgiphy.gif","Gif","width:320px;max-width:100%;",[343,360,361],{},"Du coup nous prenons le pdf comme une image de fond et nous écrivons par dessus les bonnes données\nde chaque client. Il nous faut donc les bonnes coordonnées dans le pdf.",[343,363,364],{},"Nous avons plusieurs problématiques.",[366,367,369],"h3",{"id":368},"différence-entre-pdfs","Différence entre PDFs",[343,371,372,373,379,382],{},"La première difficulté est de voir la différence entre 2 millésimes. Nous utilisons pour ça l'outil\ndiff-pdf\n(",[374,375],"a",{"href":376,"rel":377},"https:\u002F\u002Fvslavik.github.io\u002Fdiff-pdf\u002F",[378],"nofollow",[374,380,376],{"href":376,"rel":381},[378],").",[343,384,385,386,390,393],{},"Pour l'installer sur mac c'est facile (pour les autres OS je vous laisse regarder ici :\n",[374,387],{"href":388,"rel":389},"https:\u002F\u002Fgithub.com\u002Fvslavik\u002Fdiff-pdf#obtaining-the-binaries",[378],[374,391,388],{"href":388,"rel":392},[378],")\n:",[395,396,400],"pre",{"className":397,"code":398,"language":399,"meta":11,"style":11},"language-sh shiki shiki-themes github-light github-dark","brew install diff-pdf\n","sh",[401,402,403],"code",{"__ignoreMap":11},[404,405,407,411,415],"span",{"class":406,"line":19},"line",[404,408,410],{"class":409},"sScJk","brew",[404,412,414],{"class":413},"sZZnC"," install",[404,416,417],{"class":413}," diff-pdf\n",[343,419,420],{},"Ensuite on peut facilement voir la différence entre 2 pdf avec la commande suivante :",[395,422,424],{"className":397,"code":423,"language":399,"meta":11,"style":11}," diff-pdf --view 2033-sd_3330.pdf 2033-sd_3723.pdf\n",[401,425,426],{"__ignoreMap":11},[404,427,428,431,435,438],{"class":406,"line":19},[404,429,430],{"class":409}," diff-pdf",[404,432,434],{"class":433},"sj4cs"," --view",[404,436,437],{"class":413}," 2033-sd_3330.pdf",[404,439,440],{"class":413}," 2033-sd_3723.pdf\n",[343,442,443],{},"La commande ouvrira une visionneuse (par contre c’est moche 😛).",[343,445,446],{},[354,447],{"alt":11,"src":448},"\u002Fimages\u002FUntitled-14.png",[338,450,452],{"id":451},"récupérer-les-coordonnées-dans-un-pdf","Récupérer les coordonnées dans un pdf",[343,454,455],{},"Afin d'avoir les coordonnées, nous pouvons utiliser facilement des outils web. Pour les curieux, le\nlien vers le code final se trouve en bas de l'article.",[343,457,458],{},"Nous commençons par créer le fichier html. Nous avons besoin d'un canvas. Nous allons aussi créer un\nspan où on mettra les coordonnées.",[395,460,464],{"className":461,"code":462,"language":463,"meta":11,"style":11},"language-html shiki shiki-themes github-light github-dark","\u003Cdiv id=\"app\">\n  \u003Cdiv class=\"coord\">Current: \u003Cspan id=\"coord\">\u003C\u002Fspan>\u003C\u002Fdiv>\n  \u003Ccanvas id=\"canvas\">\u003C\u002Fcanvas>\n\u003C\u002Fdiv>\n","html",[401,465,466,488,525,546],{"__ignoreMap":11},[404,467,468,472,476,479,482,485],{"class":406,"line":19},[404,469,471],{"class":470},"sVt8B","\u003C",[404,473,475],{"class":474},"s9eBZ","div",[404,477,478],{"class":409}," id",[404,480,481],{"class":470},"=",[404,483,484],{"class":413},"\"app\"",[404,486,487],{"class":470},">\n",[404,489,490,493,495,498,500,503,506,508,510,512,514,517,519,521,523],{"class":406,"line":12},[404,491,492],{"class":470},"  \u003C",[404,494,475],{"class":474},[404,496,497],{"class":409}," class",[404,499,481],{"class":470},[404,501,502],{"class":413},"\"coord\"",[404,504,505],{"class":470},">Current: \u003C",[404,507,404],{"class":474},[404,509,478],{"class":409},[404,511,481],{"class":470},[404,513,502],{"class":413},[404,515,516],{"class":470},">\u003C\u002F",[404,518,404],{"class":474},[404,520,516],{"class":470},[404,522,475],{"class":474},[404,524,487],{"class":470},[404,526,528,530,533,535,537,540,542,544],{"class":406,"line":527},3,[404,529,492],{"class":470},[404,531,532],{"class":474},"canvas",[404,534,478],{"class":409},[404,536,481],{"class":470},[404,538,539],{"class":413},"\"canvas\"",[404,541,516],{"class":470},[404,543,532],{"class":474},[404,545,487],{"class":470},[404,547,549,552,554],{"class":406,"line":548},4,[404,550,551],{"class":470},"\u003C\u002F",[404,553,475],{"class":474},[404,555,487],{"class":470},[343,557,558],{},"Un peu de css pour bien voir les positions.",[395,560,564],{"className":561,"code":562,"language":563,"meta":11,"style":11},"language-css shiki shiki-themes github-light github-dark",".coord {\n  background-color: black;\n  color: cornsilk;\n  width: 135px;\n  position: fixed;\n}\n","css",[401,565,566,574,588,600,616,629],{"__ignoreMap":11},[404,567,568,571],{"class":406,"line":19},[404,569,570],{"class":409},".coord",[404,572,573],{"class":470}," {\n",[404,575,576,579,582,585],{"class":406,"line":12},[404,577,578],{"class":433},"  background-color",[404,580,581],{"class":470},": ",[404,583,584],{"class":433},"black",[404,586,587],{"class":470},";\n",[404,589,590,593,595,598],{"class":406,"line":527},[404,591,592],{"class":433},"  color",[404,594,581],{"class":470},[404,596,597],{"class":433},"cornsilk",[404,599,587],{"class":470},[404,601,602,605,607,610,614],{"class":406,"line":548},[404,603,604],{"class":433},"  width",[404,606,581],{"class":470},[404,608,609],{"class":433},"135",[404,611,613],{"class":612},"szBVR","px",[404,615,587],{"class":470},[404,617,619,622,624,627],{"class":406,"line":618},5,[404,620,621],{"class":433},"  position",[404,623,581],{"class":470},[404,625,626],{"class":433},"fixed",[404,628,587],{"class":470},[404,630,632],{"class":406,"line":631},6,[404,633,634],{"class":470},"}\n",[343,636,637],{},"Puis nous allons créer le fichier index.ts",[395,639,643],{"className":640,"code":641,"language":642,"meta":11,"style":11},"language-ts shiki shiki-themes github-light github-dark","import { pdf } from \".\u002Fpdf\";\nimport * as pdfjsLib from \"pdfjs-dist\";\nimport pdfjsWorkerEntry from \"pdfjs-dist\u002Fbuild\u002Fpdf.worker.entry.js\";\npdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorkerEntry;\n\nconst canvas = document.getElementById(\"canvas\") as HTMLCanvasElement;\nconst ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D;\n\nconst load = async () => {\n  \u002F\u002F le pdf est en base64 car le site des impôts n'accepte pas les requêtes cors\n  const pdfDoc = await pdfjsLib.getDocument(pdf).promise;\n  const page = await pdfDoc.getPage(1);\n  const viewport = page.getViewport({ scale: 1.5 });\n  const renderContext = {\n    canvasContext: ctx,\n    viewport: viewport,\n  };\n  canvas.height = renderContext.viewport.height;\n  canvas.width = renderContext.viewport.width;\n  await page.render(renderContext).promise;\n\n  function getMousePos(e: MouseEvent) {\n    var rect = canvas.getBoundingClientRect();\n    return { x: e.clientX - rect.left, y: e.clientY - rect.top };\n  }\n\n  canvas.addEventListener(\n    \"click\",\n    function (e) {\n      const pos = getMousePos(e);\n\n      \u002F\u002F\u002F check x and y against the grid\n      const [x, y] = viewport.convertToPdfPoint(pos.x, pos.y) as any;\n      const currPos = [parseInt(x, 10), parseInt(y, 10)];\n\n      document.getElementById(\"coord\")!.textContent = `${currPos[0]}, ${currPos[1]}`;\n    },\n    false,\n  );\n};\n\nload();\n","ts",[401,644,645,661,681,695,705,710,743,773,778,799,806,829,855,880,892,898,904,910,921,932,946,951,975,994,1014,1020,1025,1037,1046,1059,1075,1080,1086,1124,1158,1163,1217,1223,1231,1237,1243,1248],{"__ignoreMap":11},[404,646,647,650,653,656,659],{"class":406,"line":19},[404,648,649],{"class":612},"import",[404,651,652],{"class":470}," { pdf } ",[404,654,655],{"class":612},"from",[404,657,658],{"class":413}," \".\u002Fpdf\"",[404,660,587],{"class":470},[404,662,663,665,668,671,674,676,679],{"class":406,"line":12},[404,664,649],{"class":612},[404,666,667],{"class":433}," *",[404,669,670],{"class":612}," as",[404,672,673],{"class":470}," pdfjsLib ",[404,675,655],{"class":612},[404,677,678],{"class":413}," \"pdfjs-dist\"",[404,680,587],{"class":470},[404,682,683,685,688,690,693],{"class":406,"line":527},[404,684,649],{"class":612},[404,686,687],{"class":470}," pdfjsWorkerEntry ",[404,689,655],{"class":612},[404,691,692],{"class":413}," \"pdfjs-dist\u002Fbuild\u002Fpdf.worker.entry.js\"",[404,694,587],{"class":470},[404,696,697,700,702],{"class":406,"line":548},[404,698,699],{"class":470},"pdfjsLib.GlobalWorkerOptions.workerSrc ",[404,701,481],{"class":612},[404,703,704],{"class":470}," pdfjsWorkerEntry;\n",[404,706,707],{"class":406,"line":618},[404,708,709],{"emptyLinePlaceholder":17},"\n",[404,711,712,715,718,721,724,727,730,732,735,738,741],{"class":406,"line":631},[404,713,714],{"class":612},"const",[404,716,717],{"class":433}," canvas",[404,719,720],{"class":612}," =",[404,722,723],{"class":470}," document.",[404,725,726],{"class":409},"getElementById",[404,728,729],{"class":470},"(",[404,731,539],{"class":413},[404,733,734],{"class":470},") ",[404,736,737],{"class":612},"as",[404,739,740],{"class":409}," HTMLCanvasElement",[404,742,587],{"class":470},[404,744,746,748,751,753,756,759,761,764,766,768,771],{"class":406,"line":745},7,[404,747,714],{"class":612},[404,749,750],{"class":433}," ctx",[404,752,720],{"class":612},[404,754,755],{"class":470}," canvas.",[404,757,758],{"class":409},"getContext",[404,760,729],{"class":470},[404,762,763],{"class":413},"\"2d\"",[404,765,734],{"class":470},[404,767,737],{"class":612},[404,769,770],{"class":409}," CanvasRenderingContext2D",[404,772,587],{"class":470},[404,774,776],{"class":406,"line":775},8,[404,777,709],{"emptyLinePlaceholder":17},[404,779,781,783,786,788,791,794,797],{"class":406,"line":780},9,[404,782,714],{"class":612},[404,784,785],{"class":409}," load",[404,787,720],{"class":612},[404,789,790],{"class":612}," async",[404,792,793],{"class":470}," () ",[404,795,796],{"class":612},"=>",[404,798,573],{"class":470},[404,800,802],{"class":406,"line":801},10,[404,803,805],{"class":804},"sJ8bj","  \u002F\u002F le pdf est en base64 car le site des impôts n'accepte pas les requêtes cors\n",[404,807,809,812,815,817,820,823,826],{"class":406,"line":808},11,[404,810,811],{"class":612},"  const",[404,813,814],{"class":433}," pdfDoc",[404,816,720],{"class":612},[404,818,819],{"class":612}," await",[404,821,822],{"class":470}," pdfjsLib.",[404,824,825],{"class":409},"getDocument",[404,827,828],{"class":470},"(pdf).promise;\n",[404,830,832,834,837,839,841,844,847,849,852],{"class":406,"line":831},12,[404,833,811],{"class":612},[404,835,836],{"class":433}," page",[404,838,720],{"class":612},[404,840,819],{"class":612},[404,842,843],{"class":470}," pdfDoc.",[404,845,846],{"class":409},"getPage",[404,848,729],{"class":470},[404,850,851],{"class":433},"1",[404,853,854],{"class":470},");\n",[404,856,858,860,863,865,868,871,874,877],{"class":406,"line":857},13,[404,859,811],{"class":612},[404,861,862],{"class":433}," viewport",[404,864,720],{"class":612},[404,866,867],{"class":470}," page.",[404,869,870],{"class":409},"getViewport",[404,872,873],{"class":470},"({ scale: ",[404,875,876],{"class":433},"1.5",[404,878,879],{"class":470}," });\n",[404,881,883,885,888,890],{"class":406,"line":882},14,[404,884,811],{"class":612},[404,886,887],{"class":433}," renderContext",[404,889,720],{"class":612},[404,891,573],{"class":470},[404,893,895],{"class":406,"line":894},15,[404,896,897],{"class":470},"    canvasContext: ctx,\n",[404,899,901],{"class":406,"line":900},16,[404,902,903],{"class":470},"    viewport: viewport,\n",[404,905,907],{"class":406,"line":906},17,[404,908,909],{"class":470},"  };\n",[404,911,913,916,918],{"class":406,"line":912},18,[404,914,915],{"class":470},"  canvas.height ",[404,917,481],{"class":612},[404,919,920],{"class":470}," renderContext.viewport.height;\n",[404,922,924,927,929],{"class":406,"line":923},19,[404,925,926],{"class":470},"  canvas.width ",[404,928,481],{"class":612},[404,930,931],{"class":470}," renderContext.viewport.width;\n",[404,933,935,938,940,943],{"class":406,"line":934},20,[404,936,937],{"class":612},"  await",[404,939,867],{"class":470},[404,941,942],{"class":409},"render",[404,944,945],{"class":470},"(renderContext).promise;\n",[404,947,949],{"class":406,"line":948},21,[404,950,709],{"emptyLinePlaceholder":17},[404,952,954,957,960,962,966,969,972],{"class":406,"line":953},22,[404,955,956],{"class":612},"  function",[404,958,959],{"class":409}," getMousePos",[404,961,729],{"class":470},[404,963,965],{"class":964},"s4XuR","e",[404,967,968],{"class":612},":",[404,970,971],{"class":409}," MouseEvent",[404,973,974],{"class":470},") {\n",[404,976,978,981,984,986,988,991],{"class":406,"line":977},23,[404,979,980],{"class":612},"    var",[404,982,983],{"class":470}," rect ",[404,985,481],{"class":612},[404,987,755],{"class":470},[404,989,990],{"class":409},"getBoundingClientRect",[404,992,993],{"class":470},"();\n",[404,995,997,1000,1003,1006,1009,1011],{"class":406,"line":996},24,[404,998,999],{"class":612},"    return",[404,1001,1002],{"class":470}," { x: e.clientX ",[404,1004,1005],{"class":612},"-",[404,1007,1008],{"class":470}," rect.left, y: e.clientY ",[404,1010,1005],{"class":612},[404,1012,1013],{"class":470}," rect.top };\n",[404,1015,1017],{"class":406,"line":1016},25,[404,1018,1019],{"class":470},"  }\n",[404,1021,1023],{"class":406,"line":1022},26,[404,1024,709],{"emptyLinePlaceholder":17},[404,1026,1028,1031,1034],{"class":406,"line":1027},27,[404,1029,1030],{"class":470},"  canvas.",[404,1032,1033],{"class":409},"addEventListener",[404,1035,1036],{"class":470},"(\n",[404,1038,1040,1043],{"class":406,"line":1039},28,[404,1041,1042],{"class":413},"    \"click\"",[404,1044,1045],{"class":470},",\n",[404,1047,1049,1052,1055,1057],{"class":406,"line":1048},29,[404,1050,1051],{"class":612},"    function",[404,1053,1054],{"class":470}," (",[404,1056,965],{"class":964},[404,1058,974],{"class":470},[404,1060,1062,1065,1068,1070,1072],{"class":406,"line":1061},30,[404,1063,1064],{"class":612},"      const",[404,1066,1067],{"class":433}," pos",[404,1069,720],{"class":612},[404,1071,959],{"class":409},[404,1073,1074],{"class":470},"(e);\n",[404,1076,1078],{"class":406,"line":1077},31,[404,1079,709],{"emptyLinePlaceholder":17},[404,1081,1083],{"class":406,"line":1082},32,[404,1084,1085],{"class":804},"      \u002F\u002F\u002F check x and y against the grid\n",[404,1087,1089,1091,1094,1097,1100,1103,1106,1108,1111,1114,1117,1119,1122],{"class":406,"line":1088},33,[404,1090,1064],{"class":612},[404,1092,1093],{"class":470}," [",[404,1095,1096],{"class":433},"x",[404,1098,1099],{"class":470},", ",[404,1101,1102],{"class":433},"y",[404,1104,1105],{"class":470},"] ",[404,1107,481],{"class":612},[404,1109,1110],{"class":470}," viewport.",[404,1112,1113],{"class":409},"convertToPdfPoint",[404,1115,1116],{"class":470},"(pos.x, pos.y) ",[404,1118,737],{"class":612},[404,1120,1121],{"class":433}," any",[404,1123,587],{"class":470},[404,1125,1127,1129,1132,1134,1136,1139,1142,1145,1148,1150,1153,1155],{"class":406,"line":1126},34,[404,1128,1064],{"class":612},[404,1130,1131],{"class":433}," currPos",[404,1133,720],{"class":612},[404,1135,1093],{"class":470},[404,1137,1138],{"class":409},"parseInt",[404,1140,1141],{"class":470},"(x, ",[404,1143,1144],{"class":433},"10",[404,1146,1147],{"class":470},"), ",[404,1149,1138],{"class":409},[404,1151,1152],{"class":470},"(y, ",[404,1154,1144],{"class":433},[404,1156,1157],{"class":470},")];\n",[404,1159,1161],{"class":406,"line":1160},35,[404,1162,709],{"emptyLinePlaceholder":17},[404,1164,1166,1169,1171,1173,1175,1178,1181,1184,1186,1189,1192,1195,1198,1201,1204,1206,1208,1210,1212,1215],{"class":406,"line":1165},36,[404,1167,1168],{"class":470},"      document.",[404,1170,726],{"class":409},[404,1172,729],{"class":470},[404,1174,502],{"class":413},[404,1176,1177],{"class":470},")",[404,1179,1180],{"class":612},"!",[404,1182,1183],{"class":470},".textContent ",[404,1185,481],{"class":612},[404,1187,1188],{"class":413}," `${",[404,1190,1191],{"class":470},"currPos",[404,1193,1194],{"class":413},"[",[404,1196,1197],{"class":433},"0",[404,1199,1200],{"class":413},"]",[404,1202,1203],{"class":413},"}, ${",[404,1205,1191],{"class":470},[404,1207,1194],{"class":413},[404,1209,851],{"class":433},[404,1211,1200],{"class":413},[404,1213,1214],{"class":413},"}`",[404,1216,587],{"class":470},[404,1218,1220],{"class":406,"line":1219},37,[404,1221,1222],{"class":470},"    },\n",[404,1224,1226,1229],{"class":406,"line":1225},38,[404,1227,1228],{"class":433},"    false",[404,1230,1045],{"class":470},[404,1232,1234],{"class":406,"line":1233},39,[404,1235,1236],{"class":470},"  );\n",[404,1238,1240],{"class":406,"line":1239},40,[404,1241,1242],{"class":470},"};\n",[404,1244,1246],{"class":406,"line":1245},41,[404,1247,709],{"emptyLinePlaceholder":17},[404,1249,1251,1254],{"class":406,"line":1250},42,[404,1252,1253],{"class":409},"load",[404,1255,993],{"class":470},[343,1257,1258],{},"La ligne suivante permet de faire fonctionner correctement pdfjs-dist avec un worker.",[395,1260,1262],{"className":640,"code":1261,"language":642,"meta":11,"style":11},"import pdfjsWorkerEntry from \"pdfjs-dist\u002Fbuild\u002Fpdf.worker.entry.js\";\npdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorkerEntry;\n",[401,1263,1264,1276],{"__ignoreMap":11},[404,1265,1266,1268,1270,1272,1274],{"class":406,"line":19},[404,1267,649],{"class":612},[404,1269,687],{"class":470},[404,1271,655],{"class":612},[404,1273,692],{"class":413},[404,1275,587],{"class":470},[404,1277,1278,1280,1282],{"class":406,"line":12},[404,1279,699],{"class":470},[404,1281,481],{"class":612},[404,1283,704],{"class":470},[343,1285,1286,1287,1291],{},"Le point important du code est à la ligne 33 avec ",[1288,1289,1290],"strong",{},"viewport.convertToPdfPoint",". Cette méthode\npermet d'avoir les bonnes coordonnées à l'intérieur du pdf. Elle va convertir le x, y du navigateur\nen coordonnées du pdf.",[343,1293,1294],{},"Une fois que vous aurez cliqué sur une zone du pdf, vous allez voir les coordonnées dans le bloc\nnoir en haut à gauche.",[343,1296,1297],{},[354,1298],{"alt":11,"src":1299},"\u002Fimages\u002FUntitled-15.png",[343,1301,1302,1303,1307],{},"Vous pouvez voir le résultat ici :\n",[374,1304],{"href":1305,"rel":1306},"https:\u002F\u002Ftypescript-qgcwq5.stackblitz.io\u002F",[378],[374,1308,1309],{"href":1309,"rel":1310},"https:\u002F\u002Ftypescript-qgcwq5.stackblitz.io",[378],[343,1312,1313,1314,1318],{},"Et voir le code là :\n",[374,1315],{"href":1316,"rel":1317},"https:\u002F\u002Fstackblitz.com\u002Fedit\u002Ftypescript-qgcwq5",[378],[374,1319,1316],{"href":1316,"rel":1320},[378],[343,1322,1323],{},[1288,1324,1325],{},"❗ Le fichier pdf.ts est là car :",[1327,1328,1329,1335],"ul",{},[1330,1331,1332],"li",{},[1288,1333,1334],{},"stackblitz (free) ne permet pas de déposer un fichier",[1330,1336,1337],{},[1288,1338,1339],{},"impossible de récupérer les fichiers pdf via fetch directement par le site des impôts (ils\nbloquent les requêtes cors)",[1341,1342,1343],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":11,"searchDepth":12,"depth":12,"links":1345},[1346,1349],{"id":340,"depth":12,"text":341,"children":1347},[1348],{"id":368,"depth":527,"text":369},{"id":451,"depth":12,"text":452},"2022-04-28","Presque chaque année, les documents changent (dans notre jargon on parle de millésime) et on doit mettre à jour notre générateur de document.","fr",{},"\u002Farticles\u002F2022-04-28-recuperer-les-coordonnees-dans-un-fichier-pdf-avec-pdfjs-dist",{"title":333,"description":1351},"articles\u002F2022-04-28-recuperer-les-coordonnees-dans-un-fichier-pdf-avec-pdfjs-dist",[1358],"Tech","re8FaMpRM_q3RYqxufwEnr0HUHWaqmRI97_9hpijsBQ",1778159243933]