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
Failing that, how do I turn my rectangular link annotations invisible so they don't interfere with the link text?
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 .
Copy link to clipboard
Copied
1. you can create a plugin which adds the named destinations
Copy link to clipboard
Copied
Yes, I am writing a plugin. Do you have any sample code that does this?
Copy link to clipboard
Copied
Sorry, I don't have.
Copy link to clipboard
Copied
Links /are/ ordinary text. Links are an overlay on the page.
Copy link to clipboard
Copied
Do you have any sample C++ to create invisible links?
Copy link to clipboard
Copied
Please don’t ask for samples. Are you having trouble finding the info you want in the documentation?
Copy link to clipboard
Copied
Yes, the documentation for link options is very sketchy. It shows how to make a colored rectangle only.
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?
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
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 .
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
Copy link to clipboard
Copied
can you please send me the code for rectangular selection, i'm facing problem.
Copy link to clipboard
Copied
Why would you expect us to write your code for you?
Copy link to clipboard
Copied
Atleast explain the flow, How to select rectangular area/how to select text through arrow cursor.
I tried, Its not working.