8 Replies Latest reply: Apr 3, 2012 9:52 PM by SowbhagyaSanjeev RSS

    Moving Highlight Text ( Annot) in a page for scaling

    SowbhagyaSanjeev

      Hello,

      I have created one plug-in which should scaling the content to 5 or 10%.

       

      I have taken cos object of content and applying transformation. This works fine.

       

      According to scaling am setting annotation coordinates.

      But the problem is I have hightext text as annot.

       

      In code it is considering highlight text as a annot but it's not at all moving to new coordinates.

      What could be the problem.

       

      I want to move annotations( links, text highlight ) with scaling.

       

      Please some one help me to solve this issue.

       

      Thanks,

       

      Sow

        • 1. Re: Moving Highlight Text ( Annot) in a page for scaling
          lrosenth Adobe Employee

          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…

          • 2. Re: Moving Highlight Text ( Annot) in a page for scaling
            SowbhagyaSanjeev

            Thanks for your reply.

             

                 I am resetting rect of the annot using

             

                 PDAnnotSetRect(pdAnnot, &calRect);

             

                 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.

             

            Sow

            • 3. Re: Moving Highlight Text ( Annot) in a page for scaling
              lrosenth Adobe Employee

              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?

              • 4. Re: Moving Highlight Text ( Annot) in a page for scaling
                SowbhagyaSanjeev

                Hello Irosenth,

                 

                I am not using "Rect" key in my coding.

                For content scaling  i have done as shown below.

                 

                CosObj currentCosStream = CosDictGetKeyString(currentCosObj,  "Contents");

                 

                CString csMsg;

                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)));

                 

                for

                 

                 

                ( int

                annotIndex = 0; annotIndex < PDPageGetNumAnnots(currentPDPage); annotIndex++ )

                 

                // Create the attributes dictionary for the tranform footer

                attrDictPost = CosNewDict(cosDoc, false, 1);

                strcpy(txtPost,

                "Q");

                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

                PDPageAddCosContents(pdPage, cosArray);

                 

                //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

                 

                PDAnnotSetRect(pdAnnot, &calRect);

                }

                 

                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.

                 

                Thanks,

                Sow

                • 5. Re: Moving Highlight Text ( Annot) in a page for scaling
                  lrosenth Adobe Employee

                  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?!?!?

                  • 6. Re: Moving Highlight Text ( Annot) in a page for scaling
                    SowbhagyaSanjeev

                    Hello,

                     

                    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.

                     

                    Thanks,

                     

                    Sow

                    • 7. Re: Moving Highlight Text ( Annot) in a page for scaling
                      lrosenth Adobe Employee

                      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.)

                      • 8. Re: Moving Highlight Text ( Annot) in a page for scaling
                        SowbhagyaSanjeev

                        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.

                         

                        Thanks,

                        Sow