Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
LinkToFile Destination ID / Zoom |
Post Reply ![]() |
Author | |
samuelms ![]() Beginner ![]() Joined: 10 Feb 12 Location: United States Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() Posted: 10 Feb 12 at 4:34PM |
Is there an API available to link to a local file and set a destination id to load within that file?
Here is the API I'm aware of to link to a page within another file: However, I'd like to: 1.) Link to a destination id OR 2.) Link to a page at a specific X,Y location with a specific bounding box Width, Height with a specific zoom At the moment I do not believe this is possible. :( Is this something we can expect soon (really soon?) Also, this may be possible using javascript :: see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf page 133 openDoc method's cDest argument. Note that the cDest argument says "(optional, Acrobat 8.0)". So.. I'm not sure how many pdf viewers 1.) support javascript and 2.) would support that method argument. I may try the javascript route... but I'd REALLY love to find a non-javascript route as I don't know that javascript has wide support. See http://stackoverflow.com/questions/9219807/using-javascript-inside-a-pdf
|
|
![]() |
|
kevindebenu ![]() Moderator Group ![]() ![]() Joined: 16 Apr 12 Status: Offline Points: 7 |
![]() ![]() ![]() ![]() ![]() |
One way to achieve this is to first add a link using the AddLinkToFile function, then use the GetAnnotActionID and GetActionDest functions to obtain a DestID. Then the SetDestProperties function can be used to change the link annotation to a different type. It's not possible to link to a particular area and set the zoom too. But you can link to an area using the FitR destination type, and you can link to a left/top/zoom using the XYZ destination type. Here's an example: string SourceFile = "source.pdf"; string TargetFile = "target.pdf"; int DestPage = 2; int DestZoom = 500; double DestBoxLeft = 300; double DestBoxTop = 500; double DestBoxWidth = 200; double DestBoxHeight = 150; // Create a target document containing two pages QP.DrawText(100, 700, "Target Page 1"); QP.NewPage(); QP.DrawText(100, 700, "Target Page 2"); // On the second page, draw a box and add some text to // the top left corner of the box QP.DrawBox(DestBoxLeft, DestBoxTop, DestBoxWidth, DestBoxHeight, 0); QP.DrawText(DestBoxLeft + 5, 500 - QP.GetTextHeight() - 5, "Box is here"); // Save the target file QP.SaveToFile(TargetFile); // Create a source document QP.NewDocument(); QP.SetTextAlign(1); // Draw a label for the first hotspot and add a link to any position // on the target page (123 is used here, it will be discarded later) QP.DrawTextBox(100, 700, 100, 20, "Open Target (FitR)", 0); QP.AddLinkToFile(100, 700, 100, 20, TargetFile, DestPage, 123, 1, 1); // Get the new annotation's action, and the destination of that action, // then use the DestID to change the destination properties to "FitR", // supplying the Left, Top, Right and Bottom values. Zoom is set to // zero, it will be ignored for "FitR" int ActionID = QP.GetAnnotActionID(QP.AnnotationCount()); int DestID = QP.GetActionDest(ActionID); int DestType = 5; // FitR QP.SetDestProperties(DestID, 0, DestType, DestBoxLeft, DestBoxTop, DestBoxLeft + DestBoxWidth, DestBoxTop - DestBoxHeight); // Draw a label for the second hotspot and add a link to any position // on the target page (123 is used here, it will be discarded later) QP.DrawTextBox(100, 650, 100, 20, "Open Target (XYZ)", 0); QP.AddLinkToFile(100, 650, 100, 20, TargetFile, DestPage, 123, 1, 1); // Get the DestID as before, but use XYZ for this one. The // Right and Bottom parameters are ignored ActionID = QP.GetAnnotActionID(QP.AnnotationCount()); DestID = QP.GetActionDest(ActionID); DestType = 1; // XYZ QP.SetDestProperties(DestID, DestZoom, DestType, DestBoxLeft, DestBoxTop, 0, 0); QP.SaveToFile(SourceFile);
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store