Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6022279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:50:08+00:00 2026-05-23T03:50:08+00:00

Ok so here is the full code it keeps giving me crap about pdf_add_bookmark

  • 0

Ok so here is the full code it keeps giving me crap about pdf_add_bookmark function while PHP’s website has no documentation on this function any more

<?php

     // Declare PDF File

     $pdf = pdf_new();
     PDF_open_file($pdf, "1.pdf");

     // Set Document Properties

     PDF_set_info($pdf, "author", "BT");
     PDF_set_info($pdf, "title", "Whats a title?");
     PDF_set_info($pdf, "creator", "BT");
     PDF_set_info($pdf, "subject", "Whats a subject?");

     // Get fonts to use

     pdf_set_parameter($pdf, "FontOutline", "Arial=C:\Windows\Fonts\arial.ttf"); // get a custom font
     $font1 = PDF_findfont($pdf, "Helvetica-Bold",  "winansi", 0); // declare default font
     $font2 = PDF_findfont($pdf, "Arial",  "winansi", 1); // declare custom font & embed into file

     /*
     You can use the following Fontypes 14 safely (the default fonts)
     Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique 
     Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique 
     Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic 
     Symbol, ZapfDingbats
     */

     // make the images

     $image1 = PDF_open_image_file($pdf, "jpeg", "424698.jpg","page",$page); //supported filetypes are: jpeg, tiff, gif, png.

     //Make First Page

     PDF_begin_page($pdf, 450, 450); // page width and height.
     $bookmark = PDF_add_bookmark($pdf, "Front"); // add a top level bookmark.
     PDF_setfont($pdf, $font1, 12); // use this font from now on.
     PDF_show_xy($pdf, "First Page!", 5, 225); // show this text measured from the left top.
     pdf_place_image($pdf, $image1, 255, 5, 1); // last number will schale it.
     PDF_end_page($pdf); // End of Page.

     //Make Second Page

     PDF_begin_page($pdf, 450, 225); // page width and height.
     $bookmark1 = PDF_add_bookmark($pdf, "Chapter1", $bookmark); // add a nested bookmark. (can be nested multiple times.)
     PDF_setfont($pdf, $font2, 12); // use this font from now on.
     PDF_show_xy($pdf, "Chapter1!", 225, 5);
     PDF_add_bookmark($pdf, "Chapter1.1", $bookmark1); // add a nested bookmark (already in a nested one).
     PDF_setfont($pdf, $font1, 12);
     PDF_show_xy($pdf, "Chapter1.1", 225, 5);
     PDF_end_page($pdf);

     // Finish the PDF File

     PDF_close($pdf); // End Of PDF-File.
     $output = PDF_get_buffer($pdf); // assemble the file in a variable.

     // Output Area

     header("Content-type: application/pdf"); //set filetype to pdf.
     header("Content-Length: ".strlen($output)); //content length
     header("Content-Disposition: attachment; filename=test.pdf"); // you can use inline or attachment.
     echo $output; // actual print area!

     // Cleanup

     PDF_delete($pdf); 
?>

here is the error code returned

Fatal error: Uncaught exception 'PDFlibException' with message 'pdf_add_bookmark() expects exactly 4 parameters, 2 given' in D:\wamp\www\PDF\pdf.php:36 Stack trace: #0 D:\wamp\www\PDF\pdf.php(36): pdf_add_bookmark(Resource id #2, 'Front') #1 {main} thrown in D:\wamp\www\PDF\pdf.php on line 36
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:50:09+00:00Added an answer on May 23, 2026 at 3:50 am

    the best option if you want to write PDF is TCPDF libray. Look here: http://www.tcpdf.org/.

    It is under active development, has a lot of examples and works great. It also works very well for converting HTML to PDF (which is sometimes useful and less of an hassle than using PDF cells)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Someone posted a great little function here the other day that separated the full
Here is the full code so far: module clean #light open System open System.IO
Ok, so here's the full description of the problem I'm having: I am trying
Considering the full list of PDC videos published here what are, in your opinion,
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see
This is beyond both making sense and my control. That being said here is
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.