Support » Plugin: DK PDF » Bookmarks

  • Resolved saNNNy



    is it possible to generate bookmarks in PDF?

    If I add the following line to dkpdf_output_pdf($query) in dkpdf-functions.php, the bookmark ‘Start of the document’ is generated. So maybe I can change this line in order to generate bookmarks from the headlines e.g. h1-h5 automatically.
    $mpdf->Bookmark('Start of the document');

    Thanks for any help you can offer.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author dinamiko


    Hi saNNNy,

    Bookmarks functionallity is not implemented in DK PDF but in DK PDF Generator (pro addon), where bookmarks are generated based on the titles of your selected posts:
    eBook example generated with DK PDF Generator:

    Templates in DK PDF Generator are a bit different because loops through all your selected posts instead of getting only the content of the current post, but you can get the idea, this is the code responsible of generating the bookmarks in DK PDF Generator:

    in the template (dkpdfg-index.php) I have this:
    <h1><?php the_title();?></h1>

    then in functions (dkpdfg-functions.php) I’ve this:
    $mpdf->h2toc = array( ‘H1’=>0 );
    $mpdf->h2bookmarks = array( ‘H1’=>0 );

    for nested bookmarks you can use something like this:
    $mpdf->h2bookmarks = array( ‘H1’=>0, ‘H2’=>1, ‘H3’=>2);


    Plugin Author dinamiko


    I forgot to mention that you’ve to actually output it 🙂
    there is a line of code before of the above:

    $mpdf->WriteHTML('<tocpagebreak toc-preHTML="<h2>'. $toc_title .'</h2>"  paging="on" links="on" resetpagenum="1" toc-odd-footer-value="-1" toc-odd-header-value="-1" />');
    $mpdf->h2toc = array( 'H1'=>0 );
    $mpdf->h2bookmarks = array( 'H1'=>0 );


    Thank you very much for your fast and detailed answer. I’ll give this a try.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bookmarks’ is closed to new replies.