• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

C++ code to create text link to named destination?

Community Beginner ,
Oct 25, 2018 Oct 25, 2018

Copy link to clipboard

Copied

I'm currently using rectangle links that clip into the text that I want the user to click.

Does anybody have c++ code for Acrobat Pro DC to

  1. Create a named destination to a page number that is currently valid, but allow the user to come in later insert pages in between and retain the destination.
  2. On a different page add what appears to be (and prints as) ordinary text but is actually a link to the named destination.

Failing that, how do I turn my rectangular link annotations invisible so they don't interfere with the link text?

TOPICS
Acrobat SDK and JavaScript

Views

507

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 26, 2018 Oct 26, 2018

This turned out to need a lot more research than I was expecting, though this is fairly typical. I created two link annotations in the UI. One with a visible border and one without. The only difference was the visible one had /Border [0 0 1] while the invisible one had /Border [0 0 0]. This could be done with the Cos layer, but I believe the simplest API is likely to be PDLinkAnnotSetBorder .

Likes

Translate

Translate
Community Expert ,
Oct 25, 2018 Oct 25, 2018

Copy link to clipboard

Copied

1. you can create a plugin which adds the named destinations

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

Yes, I am writing a plugin. Do you have any sample code that does this?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

Sorry, I don't have.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

Links /are/ ordinary text. Links are an overlay on the page.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

Do you have any sample C++ to create invisible links?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

Please don’t ask for samples. Are you having trouble finding the info you want in the documentation?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

Yes, the documentation for link options is very sketchy.  It shows how to make a colored rectangle only.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

Which API do you use at the moment? I ask because there are multiple overlapping APIs. Are you trying to use only the plugin guide or are you using the API Reference too?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

Here is the C++ code I am using currently to put a white rectangle around the link. Can I make it transparent instead?

  // Box around the link

  ASFixedRect initialRect;

  initialRect.left = ASInt32ToFixed(writeLeft);

  initialRect.top = ASInt32ToFixed(writeTop -5);

  initialRect.right = ASInt32ToFixed(endText +2);

  initialRect.bottom = ASInt32ToFixed(writeTop - lrint(1.5 * fontSize));

  PDPage gotoPage = PDDocAcquirePage(pdDoc, linkedPage);

  ASFixedRect destRect;

  PDPageGetCropBox(gotoPage,&destRect);

  PDViewDestination aViewDest=PDViewDestCreate(pdDoc,gotoPage,ASAtomFromString("XYZ"),&destRect,PDViewDestNULL,0);

  PDPageRelease(gotoPage);

  PDAction aAction= PDActionNewFromDest(pdDoc,aViewDest,pdDoc);

  PDAnnot aLinkAnnot = PDPageAddNewAnnot(pdPage, -2, ASAtomFromString("Link"), &initialRect);

PDLinkAnnotSetAction(aLinkAnnot, aAction);

PDColorValueRec colourWhite;

memset (& colourWhite, 0x00, sizeof (colourWhite));

colourWhite.space = PDDeviceRGB;

colourWhite.value [0] = fixedOne;

colourWhite.value [1] = fixedOne;

colourWhite.value [2] = fixedOne;

PDAnnotSetColor(aLinkAnnot, & colourWhite);

PDAnnotSetTitle(aLinkAnnot, linkText.c_str(), linkText.length());

PDEContentAddElem(pageContent, kPDEAfterLast, reinterpret_cast<PDEElement>(textObj));   

PDPageSetPDEContentCanRaise(pdPage, NULL);   //Set the content back into the page.

PDERelease(reinterpret_cast<PDEObject>(textObj)); // Done

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

This turned out to need a lot more research than I was expecting, though this is fairly typical. I created two link annotations in the UI. One with a visible border and one without. The only difference was the visible one had /Border [0 0 1] while the invisible one had /Border [0 0 0]. This could be done with the Cos layer, but I believe the simplest API is likely to be PDLinkAnnotSetBorder .

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2018 Oct 26, 2018

Copy link to clipboard

Copied

Yes, that works. My revised code is then: (Note no color setting as the border has no width to color)

// Box around the link

  ASFixedRect initialRect;

  initialRect.left = ASInt32ToFixed(writeLeft);

  initialRect.top = ASInt32ToFixed(writeTop -5);

  initialRect.right = ASInt32ToFixed(endText +2);

  initialRect.bottom = ASInt32ToFixed(writeTop - lrint(1.5 * fontSize));

  PDPage gotoPage = PDDocAcquirePage(pdDoc, linkedPage);

  ASFixedRect destRect;

  PDPageGetCropBox(gotoPage,&destRect);

  PDViewDestination aViewDest=PDViewDestCreate(pdDoc,gotoPage,ASAtomFromString("XYZ"),&destRect,PDViewDestNULL,0);

  PDPageRelease(gotoPage);

  PDAction aAction= PDActionNewFromDest(pdDoc,aViewDest,pdDoc);

  PDAnnot aLinkAnnot = PDPageAddNewAnnot(pdPage, -2, ASAtomFromString("Link"), &initialRect);

PDLinkAnnotSetAction(aLinkAnnot, aAction);

_t_PDLinkAnnotBorder border;

PDLinkAnnotGetBorder(aLinkAnnot, &border);

border.width = 0;

PDLinkAnnotSetBorder(aLinkAnnot, &border);

PDAnnotSetTitle(aLinkAnnot, linkText.c_str(), linkText.length());

PDEContentAddElem(pageContent, kPDEAfterLast, reinterpret_cast<PDEElement>(textObj));   

PDPageSetPDEContentCanRaise(pdPage, NULL);   //Set the content back into the page.

PDERelease(reinterpret_cast<PDEObject>(textObj)); // Done

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

can you please send me the code for rectangular selection, i'm facing problem.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

Why would you expect us to write your code for you?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

LATEST

Atleast explain the flow, How to select rectangular area/how to select text through arrow cursor.

 

I tried, Its not working.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines