# [tex-live] Making texts externally replaceable in PDFs, e.g. with sed(1)

Osipov, Michael michael.osipov at siemens.com
Fri Dec 14 22:56:18 CET 2018

Ulrike,

Am 2018-12-14 um 20:20 schrieb Ulrike Fischer:
> Am Fri, 14 Dec 2018 16:50:17 +0100 schrieb Osipov, Michael:
>
>
>> So for a sed(1)-based postprocessor it is virtually impossible to map
>> "<0008002700320026002c00270008>" to "%DOCID%" w/o analyzing the PDF objects.
>
> I don't understand this. Where is the difference between
> <0008002700320026002c00270008> and (%DOCID%)? Both is a quite unique
> string.

At first sight, yes, but I don't expect the char code to glyph mapping
to be stable as long as more and more glyphs are added to bfchar. This
is likely an implemenation detail of xdvipdfmx. I don't want to rely on
that. So "<0008002700320026002c00270008>" does not always has to be
"(%DOCID%)" I guess.

>>
>> Requesting XeLaTex to produce
>>> Td[(%DOCID%)]TJ ET
>>
>> will not work
>
> It is easy:
>
> \documentclass[12pt,a4paper]{article}
>   \special{dvipdfmx:config z 0} %uncompress pdf
>
>   \begin{document}
>
>   {\fontencoding{OT1}\ttfamily \%DOCID\%
>    \makebox[0pt]{%
>     \raisebox{5cm}[0pt][0pt]{1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ}}%
>   }
>
>   bllb
>
>   \end{document}
>
> This gives -68.742 Td[(%DOCID%)]TJ in the pdf.

That's awesome, but this defeats the standard font of Siemens Sans
Global to OT1 (Mono) and will violate the required layout style of our
documentation reponsible. This isn't really something I want to do.

> The chars in the raisebox are there so that the chars perhaps needed
> for the replacement are also in the pdf.

Yep, that's issue. Due to the subset nature, this is unfortunately
required. One could also move them outside of the viewport because for
now there are visible which isn't really desired.

> Be aware that you must exchange the same number of chars. %DOCINFO%
> can be replaced by 7 other chars, but not less or more or the xref
> table will be faulty.

I noticed that too, one would need to update the stream length and the
xref table. It is feasable to make the placeholder as long as the actual
content.

Thank your for the idea, but do you know how to enforce the main font
here while retaining WinAnsiEncoding?

Michael