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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - LinkToFile Destination ID / Zoom
  FAQ FAQ  Forum Search   Register Register  Login Login

LinkToFile Destination ID / Zoom

 Post Reply Post Reply
Author
Message
samuelms View Drop Down
Beginner
Beginner


Joined: 10 Feb 12
Location: United States
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote samuelms Quote  Post ReplyReply Direct Link To This Post Topic: LinkToFile Destination ID / Zoom
    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
Back to Top
kevindebenu View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 16 Apr 12
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote kevindebenu Quote  Post ReplyReply Direct Link To This Post Posted: 17 Apr 12 at 8:01AM
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);
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store