[NTG-context] What is the luatex version of \pdfescapehex

Zhichu Chen zhichu.chen at gmail.com
Wed Jan 6 11:52:10 CET 2010


Thank you Hans,

On Wed, Jan 6, 2010 at 4:38 PM, Hans Hagen <pragma at wxs.nl> wrote:
> 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
format("%s",byte(s))
and it worked as \pdfescapename. I hope I'm not too wrong.

Anyway, my ancient module just write directly with pdfobj, I just commented
the /ModDate parameters and seems just fine now.

I think I really need to learn some lua. Thank you again for your time.

>
> 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
----------------------------------------------------------------


More information about the ntg-context mailing list