Re: Is it possible to have a PDF table of contents list?

Mark <[email protected]> Wed, 28 Nov 2018 21:08:17 +0000
Newsgroups gmane.comp.type-setting.lout
Message-ID <[email protected]>
On 2018-11-27 15:00, Valery Ushakov wrote:
> On Tue, Nov 27, 2018 at 09:09:35 -0500, Wolfram Kahl wrote:
> 
>> On Tue, Nov 27, 2018 at 08:19:13AM +0000, Mark Summerfield wrote:
>> 
>> > In my PDF viewer it can show the page thumbnails in a vertical panel,
>> > but it does not show a table of contents list in a vertical panel. (I
>> > don't need/want a generated table of contents slide, since I want manual
>> > control of that.)
>> >
>> > I _think_ this may be a Bookmarks list, but neither the user guide nor
>> > the expert guide mention bookmarks.
>> 
>> As far as I know, this does not depend on Lout-the-program,
>> but only on the library (.../lout/include) which you can extend 
>> yourself:
>> You'd need to find out what to write into the Lout-generated
>> PostScript so that your PostScript-to-PDF converter (in my case
>> `ps2pdf -dPDFSETTINGS=/prepress') generates the desired PDF features.
> 
> Lout does generate some pdfmarks internally (@LinkSource and
> @LinkDest), but you can also use @Graphics (@DocInfo in include/bsf).
> 
> Shouldn't be that hard to add pdfmarks to document structure symbols,
> like @Section, though it's been more than a decade since I looked
> closer, so I might be misremembering.
> 
> I'll try to take a look when I have time unless someone beats me to
> it.
> 
> -uwe

Thanks for that idea, I've created this:

def @TocA right x {
     {
         @BackEnd @Case {
             PostScript @Yield
             {
                 "[ /Title ("x") /OUT pdfmark " # lout provides ] ?
             }
             else @Yield @Null
             }
     } @Graphic { }
}

And it works!

One downside is that I can't do 'subordinate' bookmarks because to do 
that you need to know how many there are so that for the parent you can 
set the /Count value.