According to the documentation pdfe.status can be use to check if a pdf has been opened. But when I try \directlua{ dict=pdfe.open("testinput.pdf") pdfe.status(dict)} \bye I get an error (./test-utf8.tex[\directlua]:1: attempt to call a nil value (field 'status') And how I'm supposed to extract an object reference from a dictionary? There are commands getinteger, getstring but nothing that looks like a "getreference". -- Ulrike Fischer http://www.troubleshooting-tex.de/
---- On Fri, 22 Mar 2019 18:39:17 +0100 Ulrike Fischer
According to the documentation pdfe.status can be use to check if a pdf has been opened. But when I try
\directlua{ dict=pdfe.open("testinput.pdf") pdfe.status(dict)} \bye
I get an error (./test-utf8.tex[\directlua]:1: attempt to call a nil value (field 'status')
The function actually exists but it is called `getstatus` instead of `status`.
And how I'm supposed to extract an object reference from a dictionary? There are commands getinteger, getstring but nothing that looks like a "getreference".
Normally you do need to do this, just use `getdictionary` etc. and references get resolved automatically.
If you really need the reference, use getfromdictionary. In contrast to the documentation, this function also
accepts a key instead of an index. (If called with a key, the key is not returned.)
If the key points to a reference, the function returns the type 10, the reference object and the reference number
(This is also different than the documentation, which suggests that it only returns the number.)
Also getfromreference does not only return the referenced object, but also it's type.
So you get
local file = pdfe.open'main.pdf'
print('Status: ' .. pdfe.getstatus(file))
local catalog = pdfe.getcatalog(file)
local t, ref, refnum = pdfe.getfromdictionary(catalog, 'Names')
if t ~= 10 then
error[[No reference found]]
end
print(refnum, pdfe.getfromreference(ref))
-- An easier way to get the same dictionary:
print(catalog.Names)
pdfe.close(file)
Resulting in the output (for some example main.pdf file):
Status: 0
94 8
-- Ulrike Fischer http://www.troubleshooting-tex.de/
_______________________________________________ dev-luatex mailing list dev-luatex@ntg.nl https://mailman.ntg.nl/mailman/listinfo/dev-luatex
Am Fri, 22 Mar 2019 19:48:46 +0100 schrieb Marcel Krüger:
The function actually exists but it is called `getstatus` instead of `status`.
Ah ;-)
And how I'm supposed to extract an object reference from a dictionary? There are commands getinteger, getstring but nothing that looks like a "getreference".
Normally you do need to do this, just use `getdictionary` etc. and references get resolved automatically. If you really need the reference,
Well I don't know if I need it. Actually I was trying to understand the working library by solving a simple task: get and print the /Rect values of all annotations on a page (so get the /Annot entry and from its array the object numbers and then the relevant key. I will try later if I get it from your code.
Do not try to print the reference object, the tostring helper is broken so it leads to a fatal Lua error. (It uses `%i`, but it would have to use `%d` to work.)
I already got an error involving %i, I'm glad it wasn't my fault ;-) -- Ulrike Fischer https://www.troubleshooting-tex.de/
---- On Fri, 22 Mar 2019 19:48:46 +0100 Marcel Krüger
[...]
Do not try to print the reference object, the tostring helper is broken so it leads to a fatal Lua error. (It uses `%i`, but it would have to use `%d` to work.)
Hi LuaTeX team,
I noticed a change related to this in the trunk and experimental code so I just wanted to let you know that at least on my system,
that this did not fix the problem because %i is still used instead of %d. To avoid the error, you could replace
lua_pushfstring(L, "
participants (2)
-
Marcel Krüger
-
Ulrike Fischer