[Dev-luatex] pdf.obj() removes leading white space

Hans Hagen pragma at wxs.nl
Sat Mar 8 12:45:07 CET 2014


On 3/8/2014 1:46 AM, Reinhard Kotucha wrote:
> Hi,
> I'm currently trying to insert XMP metadata into a PDF file in order
> to make it PDF/A compliant.
>
> The XML stuff is a Lua string and I'm using pdf.obj() in order to
> create the object.  However, leading whitespace is renoved by
> pdf.obj().  As far as the XML stuff is concerned, it's not a big
> problem if indentation gets lost because XML parsers ignore it anyway.
>
> However, I have to add about 2..4 kB of padding and all validators
> insist on space characters (0x20).  This padding is important because
> it allows content management systems to extend the XML stuff without
> the need to re-generate the xref table.
>
> After all, I would expect that pdf.obj() allows to insert even binary
> stuff because PDF objects can contain anything.  Hence I assume that
> the current behavior is not desired.
>
> I didn't try pdf.immediateobj() yet but I fear that it's affected too.

this works quite ok

local s = [[

<foo>
     <bar>
         some crap
     </bar>
</foo>

]]

pdf.refobj(pdf.obj("stream",s))
pdf.immediateobj(s)

of course if you embed that kind of lua code in a tex file then you have 
to make sure that you use a catcode regime that retains spaces ..

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the dev-luatex mailing list