Q:
How do I create links from one PDF document to a specific section of a
separate document?
----
A:
Using PDFNet SDK (www.pdftron.com/net) you can create links from one
PDF document to a specific section of a separate document.
For example:
FileSpec fs = FileSpec.Create(doc, "myexternal.pdf", false);
// or FileSpec fs = FileSpec.CreateURL (doc, "http://foobar.com/
myexternal.pdf");
Action action = Action.CreateGotoRemote(fs, 1);
The 'action' object can then be associated with a link annotations
(see http://www.pdftron.com/net/samplecode.html#Annotation) or with a
bookmark items (see http://www.pdftron.com/net/samplecode.html#Bookmark).
The following sample code illustrates how to create a Bookmark to a
page in a remote document. A remote go-to action is similar to an
ordinary 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.
//---------------------------------
PDFNet.Initialize();
PDFDoc doc = new PDFDoc("bookmark.pdf");
doc.InitSecurityHandler();
// Create file specification dictionary by hand (the file referred to
by the remote bookmark)
Obj file_spec = doc.CreateIndirectDict();
file_spec.Put("Type", Obj.CreateName("Filespec"));
file_spec.Put("F", Obj.CreateString("bookmark.pdf"));
FileSpec spec = new FileSpec(file_spec);
// The second parameter is the page number... (so, jump to page #5)
Action goto_remote = Action.CreateGotoRemote(spec, 5, true);
Bookmark remoteBookmark1 = Bookmark.Create(doc, "REMOTE BOOKMARK 1");
remoteBookmark1.SetAction(goto_remote);
doc.AddRootBookmark(remoteBookmark1);
doc.Save("bookmark_remote.pdf", Doc.SaveOptions.e_linearized);
doc.Close();
//---------------------------------
Using PDFNet SDK you can also create remote goto links using 'named
destinations' instead of explicit page numbers. Named destinations can
be created using PDF.Destination and SDF.NameTree class.