What is the luatex version of \pdfescapehex
![](https://secure.gravatar.com/avatar/117a058bed6945e7fa1b40ff2f6e7aa7.jpg?s=120&d=mm&r=g)
Hi, I've written a very old module which used a lot of pdf primitives like \pdfescapehex and \pdfescapename etc. and it turns out not they don't work in mkiv. So I just want to know are there any alternatives? TIA -- Best Regards Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 6-1-2010 2:33, Zhichu Chen wrote:
Hi,
I've written a very old module which used a lot of pdf primitives like \pdfescapehex and \pdfescapename etc. and it turns out not they don't work in mkiv. So I just want to know are there any alternatives?
just lua code as placeholders for primitives will not show up in context mkiv \startluacode local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes local gsub, format, byte = string.gsub, string.format, string.byte function commands.hexify(str) texsprint(ctxcatcodes,(gsub(str,".",function(s) return format("%0X",byte(s)) end))) end \stopluacode \long\def\hexify#1{\ctxlua{commands.hexify([[#1]])}} \hexify{I wonder why this is needed.} btw, if your old module produces pdf and uses other \pdf... primitives it's unlikely to work with mkiv anyway so you'd better check if it's still needed Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/117a058bed6945e7fa1b40ff2f6e7aa7.jpg?s=120&d=mm&r=g)
On 6-1-2010 2:33, Zhichu Chen wrote:
Hi,
I've written a very old module which used a lot of pdf primitives like \pdfescapehex and \pdfescapename etc. and it turns out not they don't work in mkiv. So I just want to know are there any alternatives?
just lua code as placeholders for primitives will not show up in context mkiv
\startluacode local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes local gsub, format, byte = string.gsub, string.format, string.byte function commands.hexify(str) texsprint(ctxcatcodes,(gsub(str,".",function(s) return format("%0X",byte(s)) end))) end \stopluacode
\long\def\hexify#1{\ctxlua{commands.hexify([[#1]])}}
\hexify{I wonder why this is needed.}
btw, if your old module produces pdf and uses other \pdf... primitives it's unlikely to work with mkiv anyway so you'd better check if it's still needed Yes, \pdffilemoddate, \pdffilesize, \pdfmdfivesum are kind of disabled as well, I'm not familiar with lua at all, so I don't know how to replace them with the lua version. I did change your code format("%0X",byte(s)) with
Thank you Hans,
On Wed, Jan 6, 2010 at 4:38 PM, Hans Hagen
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
-- Best Regards Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/117a058bed6945e7fa1b40ff2f6e7aa7.jpg?s=120&d=mm&r=g)
Sorry to my previous posts. I found a LaTeX package named pdftexcmds and the lua script works just fine.
participants (2)
-
Hans Hagen
-
Zhichu Chen