
최신 버전의 LuaTeX에서는 PDF 개요 계층 구조를 TeX 측에서 다음과 같이 설정할 수 있습니다 \pdfextension outline
. 예를 들어:
\pdfextension outline goto page \the\c@page {} count 1 {Chapter 1}
\pdfextension outline attr{/F 1} goto name{label} {Section 1.1}
Lua에서 이 작업을 수행하고 싶습니다. 다음과 같은 것 :
pdf.setoutlines( whatever )
...그런데 그런 인터페이스가 없어요.
를 사용하여 원시 PDF 개체를 사용하는 것에 대해 생각해 보았지만 pdf.immediateobj
그렇게 해야 할지 모르겠습니다. 그렇게 하는 것이 가능하다면 계층 구조의 예를 보여 주시겠습니까?
답변1
예, 원시 PDF 개체를 작성해야 합니다. 다음은 북마크된 두 페이지로 구성된 최소한의 예입니다.
파일 outlines-example.tex
(일반으로 컴파일 luatex
):
This is the first page.
\vfil\break
This is the second page.
\directlua{require('outline-examples')}
\bye
파일 outlines-example.lua
:
-- Reserve all object numbers beforehand
local first, second, outlines =
pdf.reserveobj(), pdf.reserveobj(), pdf.reserveobj()
-- Write out the bookmarks
pdf.immediateobj(first, string.format(
'<< /Title (First page) /Parent %d 0 R /Next %d 0 R /Dest [0 /XYZ] >>',
outlines, second))
pdf.immediateobj(second, string.format(
'<< /Title (Second page) /Parent %d 0 R /Prev %d 0 R /Dest [1 /XYZ] >>',
outlines, first))
-- Write out the outline dictionary
pdf.immediateobj(outlines, string.format(
'<< /Type/Outlines /First %d 0 R /Last %d 0 R /Count 2 >>',
first, second))
-- Add the outline dictionary to the document catalog
pdf.setcatalog(string.format(
'%s /Outlines %d 0 R',
pdf.getcatalog() or '', outlines))