How to replace the selected word using C++?


currently getting selected test

 

i using callback call below function

static accb1 asbool accb2 pdtextselectenumtextproccb(void* procobj, pdfont font, asfixed size, pdcolorvalue color, char* text, asint32 textlen)

 

from information replace text.

 

i try using below example adding new text in new page

 

    pdetext pdetext = pdetextcreate();

    create degraphicstate object , set attributes

    asfixedmatrix textmatrix;

    create asfixedmatrix object

    memset(&textmatrix, 0, sizeof(textmatrix)); /* set buffer size */

    textmatrix.a = int16tofixed(24); /* set font width , height */

    textmatrix.d = int16tofixed(24); /* 24 point size */

    textmatrix.h = int16tofixed(1*72); /* x,y coordinate on page */

    textmatrix.v = int16tofixed(2*72); /* in case, 1" x 2" */

 

pdecolorspace pdecolorspace = pdecolorspacecreatefromname(asatomfromstring(colour_space.c_str()));

    memset(&gstate, 0, sizeof(pdegraphicstate));

    gstate.strokecolorspec.space = gstate.fillcolorspec.space = pdecolorspace;

    gstate.miterlimit = fixedten;

    gstate.flatness = fixedone;

    gstate.linewidth = fixedone;

   

   

    //create character pointer

    char *helloworldstr = "hello there";

    //create new text run

    pdetextadd(pdetext, //text container add to

               kpdetextrun, // kpdetextrun

               0, // in

               helloworldstr, // text add

               strlen(helloworldstr),// length of text

               font, // font apply text

               &gstate, //address of pdegraphicstate object

               sizeof(gstate), //size of graphic state apply text

               null,

               0,

               &textmatrix, //transformation matrix text

               null); //stroke matrix

    //insert text page content

    pdecontentaddelem(pdecontent, kpdeafterlast, (pdeelement) pdetext);

this very, very, tricky do, in general case, though may reasonably simple. if trying write general "search , replace" plug-in discover hard adobe never did in 20 years.

 

you need analyse of text runs in page, looking 1 remove. complications:

1. encoding of text might not match current encoding, might not find it.

2. following text might dependent on position of text, or not. if change text run, text might move, or overlap or gap might open

3. text run might include word part of it, not whole run, you'd have edit text in run.

4. text search might split on multiple runs , text objects. in cases might not consecutive or in order.



More discussions in Acrobat SDK


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account