Q: Is it possible to add link to a PDF document to navigate to a
location of a page of second PDF document using PDFNet?
Example: first.pdf has a link-second.pdf#location. I would like to
create several PDF documents that will reference to special locations
of pages to each other.
--------
A: You would need to create a 'remote goto action' (i.e. GoToR
action).
The following sample shows how to create a GoToR action & link.
// Create 'relative' FileSpec 'by hand'.
Obj file_spec = doc.CreateIndirectDict();
file_spec.PutName("Type", "Filespec");
file_spec.PutString("F", "dest.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);
Annot link = Annot.CreateLink(doc.GetSDFDoc(), new Rect(85, 458, 503,
502), goto_remote);
page.AnnotPushBack(link);
In case you would like to create a 'Remote GoTo' action (i.e. GoToR
action) to a 'named' destination object in an external PDF document,
you could use the following snippet:
Action goto_remote = Action.CreateGotoRemote (spec, 0, true);
// Set the destination to be the key of the
// named destination in the remote PDF.
goto_remote.PutString("D", "MyDest");
Annot link = Annot.CreateLink(doc.GetSDFDoc(), new Rect(85, 458, 503,
502), goto_remote);
page.AnnotPushBack(link);
This code assumes that the remote document contains the named
destination called "MyDest".
-------
In case you need to create hyperlinks or intra-document links, please
take a look at Annotation sample project (
http://www.pdftron.com/net/
samplecode.html#Annotation)