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

Reinhard Kotucha reinhard.kotucha at web.de
Sun Mar 9 00:30:03 CET 2014

On 2014-03-08 at 12:45:07 +0100, Hans Hagen wrote:

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

Hi Hans,
thank you for the response.  I'm still confused.  I didn't expect that
I have to care about catcodes when I use pure lua functions.

But there are some oddities.  First of all, in my actual project I'm
using pdf.immediateobj() and it seems to work there.  But I don't know
why it works there but not in my MWE (see attachment).

Of course, I could continue but I hesitate to add more complexity
until I completely grok what's going on.  I fear that I break it when
I change something anywhere else.

What also confuses me is that in the MWE spaces are preserved unless
they appear at the beginnig of a line.  I.e., the line

            <!--                         -->

appears as
<!--                         -->

in the PDF file.  I would expect that with \catcode32=10 all spaces
are collpsed and leading spaces are ignored but with \catcode32=12 all
spaces are pertained.

If you try the MWE on Linux, just run the makefile.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mwe-testxmp.tar.gz
Type: application/x-gzip
Size: 1684 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/dev-luatex/attachments/20140309/04060b02/attachment.bin>
-------------- next part --------------


Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.

More information about the dev-luatex mailing list