mananaysiempre
today at 6:03 PM
As usual, there’s a number of ways to do this.
You can put the actual document content in an image and duplicate the textual data it contains using invisible text objects (popular for scanned books). You can specify what Unicode characters underlie the glyph used in your text objects (essentially required for copy&paste to work once the document goes beyond ASCII, or even just uses prebaked ligatures in the font). You can attach arbitrary files, which may contain the document’s plaintext source if you so choose (some do this with their LaTeX documents).
Finally, the closest to what you want is “tagged PDF”, required by some accessibility and archival profiles. As best as I understand, it essentially annotates the text content of the document with semantic markup (which is in normal viewers is invisible and completely ignored). Unfortunately, tagging is only specified in PDF ≥2.0, which ISO in its infinite wisdom decided (in spite of its promises to Adobe once upon a time) to put behind a paywall, unlike the earlier, Adobe-produced versions; and associated best-practices profiles like PDF/A and PDF/UA were born paywalled. Nowadays PDF and PDF/UA, at least, are login-walled and watermarked but gratis[1], yet tagging still seems to mostly be treated as an expensive compliance concern for those subject to such. There is in particular no decent way to make tagged PDFs from LaTeX despite ongoing work (unsurprisingly, as it would need to be an ecosystem-wide effort on the scale of tex4ht).
[1] Remember to hoard copies: e.g. quite a few public standards from the 2000s reference specifically Unicode 3.0 and not any later version, while linking to the free copy of ISO 10646-1:2000 on the ISO website. ISO has now deleted that copy because of a policy to only make the latest version freely available.