[luatex] Creating pdf_dest nodes
Michal Vlasák
lahcim8 at gmail.com
Sat May 1 23:01:22 CEST 2021
On Sat May 1, 2021 at 10:38 PM CEST, Andreas Matthias wrote:
> In the following example I tried to create two pdf destinations,
> the first one using /pdfextension, and the second one using the
> node library. However only the first one is available, while
> the second one is missing. What am I doing wrong?
>
> \pdfvariable compresslevel = 0
>
> \pdfextension dest name {aaa} xyz zoom 2000
>
> \directlua{
> d = node.new('whatsit', 'pdf_dest')
> d.width = 100*65536
> d.height = 100*65536
> d.depth = 0
> d.named_id = true
> d.dest_id = 'bbb'
> d.dest_type = 0
> d.xyz_zoom = 2
> node.write(d)
> }
> \bye
`node.named_id` should be 1 for named destinations. Also as far as I
know dimension have no sense in the context of PDF destinations and the
zoom level should be multiplied by 1000 in both cases.
I extended your code with two ways you can "debug" similiar issues next
time:
\input nodetree
\NodetreeRegisterCallback{preout}
\pdfvariable compresslevel = 0
\setbox0=\hbox{\pdfextension dest name {aaa} xyz zoom 2000}
\copy0
\directlua{
local dest = tex.getbox(0).head
local fields = {"attr", "width", "height", "depth", "named_id",
"dest_id", "dest_type", "xyz_zoom", "objnum"}
d = node.new('whatsit', 'pdf_dest')
d.named_id = 1
d.dest_id = 'bbb'
d.dest_type = 0
d.xyz_zoom = 2000
node.write(d)
for _, field in ipairs(fields) do
print(field, dest[field], d[field])
end
}
\bye
Other way of finding out the "magic values" is looking at the source
code e.g. use of macro "set_pdf_action_named_id" and types like
typedef enum {
pdf_dest_xyz = 0,
pdf_dest_fit = 1,
pdf_dest_fith = 2,
pdf_dest_fitv = 3,
pdf_dest_fitb = 4,
pdf_dest_fitbh = 5,
pdf_dest_fitbv = 6,
pdf_dest_fitr = 7
} pdf_destination_types;
(This one is in https://git.texlive.info/texlive/tree/Build/source/texk/web2c/luatexdir/pdf/pdfdest.h.)
Michal
More information about the luatex
mailing list.