function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Richie DRichie D 

Table of Contents in a pdf

Hi,

 

I'm trying to create a table of contents in a visualforce page rendered as a pdf. Has anybody done this? Is this even possible?

 

I'm looking for something that would end up looking like:-

 

1. Lorem Ipsum......................1

2. Lorem Ipsum......................2

3. Lorem Ipsum......................2

4. Lorem Ipsum......................3 

 

(heading).............................(page number)

 

I know I can do the first bit but I don't have any way of knowing which page the heading will fall on due to differing content lengths.

 

Thanks for any help.

Rich.

RustanRustan

I think this can be achieved by using JQuery.

Jason HartfieldJason Hartfield

This can be done using the <bookmark> tag in the <head> of the document:

<apex:page renderAs="pdf" showHeader="false" standardStylesheets="false" applyHtmlTag="false" standardcontroller="Account">
  <html>
    <head>
      <bookmarks>
          <bookmark name="Bookmark Item 1" href="#anchor1"/>
      </bookmarks>
    </head>
    <body>
       <!-- Bookmark will scroll to this location -->
      <a name="anchor1"/>
    </body>
  </html>
</apex:page>
 

The PDF Renderer, just FYI, is part of this old project:

https://code.google.com/archive/p/flying-saucer/

prahlad bandhuprahlad bandhu
Hi 
<apex:page renderAs="pdf" showHeader="false" standardStylesheets="false">
    <apex:pageBlock title="Table of Contents">
        <!-- Add TOC entries here -->
        <apex:pageBlockSection title="Section 1" />
        <apex:pageBlockSection title="Section 2" />
        <apex:pageBlockSection title="Section 3" />
    </apex:pageBlock>

    <!-- Content of the PDF page -->
    <apex:pageBlock title="Page 1">
        <!-- Page 1 content goes here -->
    </apex:pageBlock>

    <apex:pageBlock title="Page 2">
        <!-- Page 2 content goes here -->
    </apex:pageBlock>

    <apex:pageBlock title="Page 3">
        <!-- Page 3 content goes here -->
    </apex:pageBlock>
</apex:page>

<style> .page-break { page-break-before: always; } </style>

Thanks
Prahlad Bandhu