In general, what you'd need to do is to generate a new ToUnicode CMap; see
section 9.10 of the PDF spec, there's an optional ToUnicode entry in the
font dictionary. The tricky part is figuring out what the new CMap should
contain, since that's going to be specific to the encoding problem you're
encountering.
The mechanics of it are fairly simple, though; given the Font object in
question and the text of the new CMap, do something like:
PdfDictionary& fontDict = font.GetDictionary();
PdfObject* cmapObj = doc.GetObjects().CreateObject();
PdfStream* stream = cmapObj->GetStream();
stream->Set(cmapText.data(), cmapText.size());
fontDict.AddKey(PdfName("ToUnicode"), cmapObj->Reference());
On Sun, Nov 3, 2019 at 4:43 PM Pietro Paolini <
pietro.paol...@cognitivecredit.com> wrote:
> Hi everybody,
>
> From time to time I come across PDFs whose fonts are broken and that I
> cannot paste from. I think this has to do with their cmaps and I am
> wondering if there is an example somewhere (if this is possible at all)
> where a document's font is amended, that is, its cmap is altered and its
> changes saved so that subsequent programs opening the document won't be
> affected by the problem.
>
> Sometimes it can be quite bizarre as only a handful of characters are
> not correctly mapped into unicode.
>
> In PoDoFo terminology it seems that I'd need to create my own
> PdfEncoding subclass and assign it to a font somehow, but I haven't
> found any example.
>
> Is this possible at all ?
>
>
> Thanks,
> Pietro
>
>
> ___
> Podofo-users mailing list
> Podofo-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/podofo-users
>
--
Clayton Wheeler
cwhee...@genomenon.com
___
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users