Handling annots when scaling is a bit harder.
You can simply adjust the Rect of the annot, though that may clip the contents vs. actually scaling the annot as well. If you need to scale the appearance, then you need to modify that too…
Thanks for your reply.
I am resetting rect of the annot using
It works fine for the Links. Suppose if the document contains Text Highlight, then it's not resetting annot.
So, you want me to do scaling for annots.
Please let me know.
I don’t know what “not resetting” means. Are you saying that the /Rect key is not changing? Are you saying that the drawing isn’t changing?
I am not using "Rect" key in my coding.
For content scaling i have done as shown below.
CosObj currentCosStream = CosDictGetKeyString(currentCosObj, "Contents");
csMsg.Format( _T( "q 1 0 0 1 %d %d cm"),x, y);
// Applying transformation matrix here
streamPre = ASMemStmRdOpen(txtPre, strlen(txtPre));
attrDictPre = CosNewDict(cosDoc, false, 1);
CosDictPut(attrDictPre, ASAtomFromString("Length"), CosNewInteger(cosDoc, false, strlen(txtPre)));
annotIndex = 0; annotIndex < PDPageGetNumAnnots(currentPDPage); annotIndex++ )
// Create the attributes dictionary for the tranform footer
attrDictPost = CosNewDict(cosDoc, false, 1);
streamPost = ASMemStmRdOpen(txtPost, strlen(txtPost));
cosArray = CosNewArray(cosDoc, true, 3);
// Put all 3 CosStreams into a CosArray (Transform Header, Contents, Transform Footer)
CosArrayPut(cosArray, 0, cosStreamPre);
CosArrayPut(cosArray, 1, currentCosStream);
CosArrayPut(cosArray, 2, cosStreamPost);
// Replace the contents of the page with the new CosArray including the transform
//Here am taking annots
for( int annotIndex = 0; annotIndex < PDPageGetNumAnnots(currentPDPage); annotIndex++ )
pdAnnot = PDPageGetAnnot(currentPDPage, annotIndex);
AWidth = (Ax2-Ax1)*(iPercentage/100.0)/2.0;
AHeight = (Ay2-Ay1)*(iPercentage/100.0)/2.0;
//According to percentage value am resetting annot using
This works fine for links. but this is not working text highlight.
Please let me know what mistake i have done here or shall i do scaling taking keywords as "Annots"
Please let me know.
PDAnnotSetRect() – you are setting the rect of the annotation.
But as I said, I still don’t understand what “doesn’t work” means. Is the rect not changing? It is changing but not the way you want? What?!?!?
The text highlight is not changing the position. The text highlight should change with text.
Please let me know how to reset the text highlight position.
I would check the PDF format data itself to see what it says – for example, is the rect actually getting changed? What about the appearance, is it adjusted? (etc.)
Thanks for reply Irosenth.
The PDF content appearance shows fine after scaling. Links rectangle appearance works fine after scaling. Only the problem is Text highlight appearance is not changing. It remains the same position.
What could be the reason.
Please help me to solve this issue.