This work was produced to be used for UNESCO but UNESCO is absolutely not linked in any way with this GITHUB project itself.
This work is very specific. Don't try to use it as it is. I published it on GITHUB to illustrate some techniques I had to set up.
The program is used to produce PDFs for previously scanned documents. We got the documents as a bunch of one page PDF (image + masked OCR test) + JPEG2000 images (.jp2) for the same pages. The produced pdf contains all the pages of one document, image coming from the .jp2 files + binarized for size optimization (converted to black&white without grey shade), masked text coming from the masked text of initial pdf files.
The binarization uses ImageMagick. The parameters can be found in const CONVERT_PARAMS. See LaunchConvertOnePage. To speed up processing, the program uses several threads to take advantage of multi-processor machine. See class CWorker.
This is done in DoMergeOCR. It uses iText7. The program, for each page, copy the page from the initial pdf, remove image, resize (what I got had fancy physical sizes) and add image from binarized pdf resulting from ImageMagick binarization.
The resulting pdf had one font per page, resulting of the font from each single page of the original (OCR) pdfs. The font (always the same) actually contains no glyph as the text is masked. But it is mandatory in pdf structure and used when searching the document or copying selected text. Even if not very big, the duplicated fonts make the resulting pdf unnecessarily fat. DoMergeFontsDoc modify each other page to use the font from the first one and remove unused fonts.