u-fischer / newpax

12 stars 3 forks source link

Internal links using /Dest are not transferred #27

Open yhxnf opened 4 months ago

yhxnf commented 4 months ago

I am using newpax (Version 0.55) and noticed that for some PDFs internal links are not transferred. After some investigation I figured that the problem is that the DestName field is missing in the corresponding entry in the .newpax file. If my understanding is correct, this happens if the PDF uses the /Dest and not /A/D field to store the destination of the link. I was able to fix this by changing the __writepax function in newpax.lua so that the if annottable.Dest case includes a

if type == 6 then
    WRITE ( outputKV_goto_name(annotgoto) )
end

before the end symbols are inserted.

I neither understand how PDFs nor how newpax works so I do not really know if the above is sane or how the newpax source files should be changed to incorporate the above.

A PDF where this happens can be found here (I initially noticed the problem for other papers published with Springer but those are not open access yet) .

Lukas

fkj commented 4 months ago

Thanks for investigating this Lukas! I can confirm that the suggested patch also fixes this issue when including a PDF I published with Springer. I have another PDF (an uncorrected proof from Springer LNCS) for which links are not transferred.

Possibly related: I have a third PDF (an uncorrected proof from a Springer journal), which stops with the following when running lualatex on the extraction file:

This is LuaHBTeX, Version 1.18.0 (TeX Live 2024/Arch Linux)
 restricted system commands enabled.
(./doc-extract-newpax.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-20>
 (/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo))./newpax.lua:433: bad argumen
t #2 to 'GETPAGE' (number expected, got nil)
stack traceback:
    [C]: in function 'pdfe.getpage'
    ./newpax.lua:433: in upvalue 'outputENTRY_dest'
    ./newpax.lua:533: in upvalue '__writepax'
    ./newpax.lua:607: in function 'newpax.writenewpax'
    [\directlua]:1: in main chunk.
l.14   }

Lua line 433 in the above is local mediabox = pdfe.getbox(GETPAGE(pdfedoc,pagenum),"MediaBox"). I have no idea if this error is actually related or if it is a different issue, and I don't have the skills to determine this. I sadly cannot share the PDF files (yet - but I don't know if the issue will persist for the published versions or if it just for the proof copies).

u-fischer commented 4 months ago

I fixed the issue in a branch and when I get some time will make an update.

I sadly cannot share the PDF files

well while I can guess what the problem is (and it is a different one), without a PDF to run some tests I can't fix it. Open a new issue once you have an example.

fkj commented 4 months ago

Thanks Ulrike for the preliminary diagnosis. I will test with the published PDFs when they are available and open a new issue if they still cause problems.

fkj commented 1 month ago

I have now gotten the published PDFs, which don't exhibit the same problem as I described above. So I will sadly not be able to give an example PDF to test with. Sorry! Happily, there are probably very few cases where someone needs to include Springer proofs into another document.