[pdftex] layer-based presentations
Pawel Jackowski
jackos1 at poczta.onet.pl
Sun Nov 7 14:04:46 CET 2004
CV Radhakrishnan wrote:
> I am interested in it very much.
>
> Thanks in advance.
Hi,
the attached file contains generic sample (pdfeTeX) and result pdf file
with log. eTeX features are not essential but convenient in this case. I
don't have an alfa-implementation already. Working on it.
Best regards, Pawel
-------------- next part --------------
This is pdfeTeXk, Version 3.141592-1.11a-2.1 (Web2c 7.5.2) (format=pdfetex 2003.10.28) 7 NOV 2004 13:58
entering extended mode
\write18 enabled.
%&-line parsing enabled.
(d:/TeX/texmf/web2c/cp8bit.tcx)
**lay-nav.tex
(./lay-nav.tex{d:/TeX/texmf/pdftex/config/pdftex.cfg} [1{d:/TeX/texmf/fonts/map
/pdftex/updmap/pdftex.map}] [2] ){d:/TeX/texmf/dvips/tetex/f7b6d320.enc}<d:/TeX
/texmf/fonts/type1/bluesky/cm/cmr10.pfb><d:/TeX/texmf/fonts/type1/bluesky/cm/cm
bx10.pfb>
Output written on lay-nav.pdf (2 pages, 20151 bytes).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lay-nav.pdf
Type: application/pdf
Size: 20150 bytes
Desc: not available
Url : http://tug.org/pipermail/pdftex/attachments/20041107/bbd205c5/lay-nav-0001.pdf
-------------- next part --------------
% to see what happens
\pdfcompresslevel=0
\pdfpagewidth=10cm
\pdfpageheight=10cm
\pdfhorigin=1cm
\pdfvorigin=1cm
\hsize=8cm
\vsize=8cm
% handy macros
\def\obj{\immediate\pdfobj}
\def\objref#1{\space\expandafter\doobjref\number#1\relax}
\def\doobjref#1\relax{#1 0 R}
\def\objrefs#1{%
\ifx#1\relax
\space
\else
\objref{#1}\expandafter\objrefs
\fi}
\def\lastobjref{\objref\pdflastobj}
\def\thisobjref{\objref{\numexpr\pdflastobj+1\relax}}
\def\nextobjref{\objref{\numexpr\pdflastobj+2\relax}} % eTeX needed
% lets make 3 layers
\def\openlayer{ BDC}
\def\closelayer{ EMC}
\obj{<< /Type /OCG /Name (Issue 1) >>}
\def\onercname{/OC1} % resource name
\edef\oneobjnum{\the\pdflastobj} % object number
\edef\one{ /OC \onercname} % code for \pdfliteral
\obj{<< /Type /OCG /Name (Issue 2) >>}
\def\tworcname{/OC2}
\edef\twoobjnum{\the\pdflastobj}
\edef\two{ /OC \tworcname}
\obj{<< /Type /OCG /Name (Issue 3) >>}
\def\threercname{/OC3}
\edef\threeobjnum{\the\pdflastobj}
\edef\three{ /OC \threercname}
% we have to add layer information to page resources...
\obj{% map names to objcts
<<
\onercname\space\objref\oneobjnum \space
\tworcname\space\objref\twoobjnum \space
\threercname\space\objref\threeobjnum \space
>>
}
\edef\layersnames{\lastobjref}
\edef\next{\pdfpageresources={/Properties \layersnames}}
\next
% ... and to document catalog (layers are global!)
\edef\layersorder{\objrefs\oneobjnum\twoobjnum\threeobjnum\relax}
\edef\layerson{\objrefs\oneobjnum\relax}
\edef\layersoff{\objrefs\twoobjnum\threeobjnum\relax}
\obj{% layers default configuration
<<
/Order [\layersorder] \space
/ON [\layerson ] \space
/OFF [\layersoff ] \space
>>
}
\edef\layersconfig{\lastobjref}
\pdfcatalog{%
/OCProperties
<<
/OCGs [\layersorder ]\space
/D \layersconfig \space
>>
}
% now we can put some text on layers (Acrobat 6 needed to see layers)
{\bf Main content of the page}
\pdfliteral{\one\openlayer}
-- layer 1
\pdfliteral{\closelayer}
\pdfliteral{\two\openlayer}
-- layer 2
\pdfliteral{\closelayer}
\pdfliteral{\three\openlayer}
-- layer 3
\pdfliteral{\closelayer}
% \end
% now the navigation part
% example of action that affects layers
\def\togglelayers{/S /SetOCGState /State [ /Toggle \layersorder ]}
\bigskip
\pdflinkmargin=2bp
Test:
\pdfstartlink
user{/Subtype /Link /A << \togglelayers\space >>}TogGle LaYerS!%
\pdfendlink
% sub-page navigation works in presentation mode only,
% so we enter fullscreen mode
\pdfcatalog{/PageMode /FullScreen}
% first we define actions to perform on user request (arrow buttons)
\obj{<<
/S /SetOCGState
/State [ /OFF \objrefs\oneobjnum\twoobjnum\threeobjnum\relax ]
>>}
\edef\actionzero{\lastobjref} % all layers off
\obj{<<
/S /SetOCGState
/State [
/ON \objrefs\oneobjnum\relax
/OFF \objrefs\twoobjnum\threeobjnum\relax ]
>>}
\edef\actionone{\lastobjref}
\obj{<<
/S /SetOCGState
/State [
/ON \objrefs\oneobjnum\twoobjnum\relax
/OFF \objrefs\threeobjnum\relax ]
>>}
\edef\actiontwo{\lastobjref}
\obj{%
<<
/S /SetOCGState
/State [ /ON \objrefs\oneobjnum\twoobjnum\threeobjnum\relax ]
>>}
\edef\actionthree{\lastobjref} % all layers on
\obj{<< /S /Named /N /NextPage >>}
\edef\actionnextpage{\lastobjref}
% each page state is represented by a navigation node
\obj{% root node
<<
/Type /NavNode
/NA \actionone
/PA \actionzero % ?
/Next \nextobjref
/Prev \thisobjref % avoid loosing current navigation node
>>}
\edef\rootnode{\lastobjref} % for page attributes
\obj{% next
<<
/NA \actiontwo % next action
/PA \actionzero % previous action
/Next \nextobjref % next node
/Prev \lastobjref % previous node (root in this case)
>>}
\obj{% next
<<
/NA \actionthree
/PA \actionone
/Next \nextobjref
/Prev \lastobjref
>>}
\obj{% last node on the page
<<
/NA \actionnextpage
/PA \actiontwo
/Prev \lastobjref
>>}
\edef\next{\pdfpageattr={/PresSteps \rootnode}}
\next
\vfill\eject
\pdfpageattr{} % forget navigation nodes for this page
\bf
Details in PDF 1.5 spec, chapter 8.
\end
More information about the pdftex
mailing list