Esempio n. 1
0
// go-to action, but jumps to a destination in another PDF file instead
// of the current file. See Section 8.5.3 'Remote Go-To Actions' in PDF
// Reference Manual for details.
// Open the document that was saved in the previous code sample
$doc = new PDFDoc($output_path . "bookmark.pdf");
$doc->InitSecurityHandler();
// Create file specification (the file referred to by the remote bookmark)
$file_spec = $doc->CreateIndirectDict();
$file_spec->PutName("Type", "Filespec");
$file_spec->PutString("F", "bookmark.pdf");
$spec = new FileSpec($file_spec);
$goto_remote = Action::CreateGotoRemote($spec, 5, true);
$remoteBookmark1 = Bookmark::Create($doc, "REMOTE BOOKMARK 1");
$remoteBookmark1->SetAction($goto_remote);
$doc->AddRootBookmark($remoteBookmark1);
// Create another remote bookmark, but this time using the low-level SDF/Cos API.
// Create a remote action
$remoteBookmark2 = Bookmark::Create($doc, "REMOTE BOOKMARK 2");
$doc->AddRootBookmark($remoteBookmark2);
$gotoR = $remoteBookmark2->GetSDFObj()->PutDict("A");
$gotoR->PutName("S", "GoToR");
// Set action type
$gotoR->PutBool("NewWindow", true);
// Set the file specification
$gotoR->Put("F", $file_spec);
// jump to the first page. Note that pages are indexed from 0.
$dest = $gotoR->PutArray("D");
// Set the destination
$dest->PushBackNumber(9);
$dest->PushBackName("Fit");
$doc->Save($output_path . "bookmark_remote.pdf", SDFDoc::e_linearized);