Quantcast
Channel: Adobe Community : All Content - Acrobat SDK
Viewing all articles
Browse latest Browse all 2571

Adding Header/Footer via Plugin

$
0
0

Hi All,

 

I am adding footer text to a PDF Document.

 

I have used the below code from adobe i can able trigger the header/footer dialogue i seen the values in textboxes as empty kindly do the needful.

I have used kAVCommandUIInteractive to keep dialogue visible.

WHere i went wrong?


InvokeAddHeadFootCmdSnip()

       ASAtom  cmdName;

                AVCommand   volatile  cmd =  NULL;

                AVCommandStatus  cmdStatus;

                volatile   ASCab  config =  NULL;

                volatile   ASCab  params =  NULL;

                volatile   ASCab  headFootCab =  NULL;

                volatile   ASCab  headFootCmdCab =  NULL;

                volatile   ASCab  headerCab =  NULL;

                volatile   ASCab  centerCab =  NULL;

                volatile   ASCab  footerCab =  NULL;

                ASBool  errorState =  false ;

                DURING

                                // Create an instance of the command.

                               cmdName =  ASAtomFromString(kAVCommandAddHeadFoot);

                               cmd =  AVCommandNew(cmdName);

                                if  (cmd==NULL){

                                                // if we cannot get the command, just alert. 

                                                AVAlertNote( "Cannot obtain the command" );

                                               errorState =  true ;

                                               

                               }

                                if  (errorState ==  false ){

                                                // We wish to invoke this command without any user interaction. See AVExpT.h for other UI policies

                                               config =  ASCabNew();

                                                ASCabPutInt(config, kAVCommandUIPolicy,  kAVCommandUIErrorsOnly);

                                                // Set command configuration 

                                               cmdStatus =  AVCommandSetConfig(cmd, config);

                                                // this command has no inputs.

                                               

                                                // we set up the parameters here, we will leave most as the default values.

                                               params =  ASCabNew();

                                               

                                                // this parameter contains two embedded ASCab objects

                                                // the first is data that is passed to the command, the other is data that drives the command.

                                               headFootCab =  ASCabNew();

                                                // we leave all parameters as the defaults except for the text...             

                                                // The actual text is maintained in two cabinets, one for the header and one for the footer.

                                               headerCab =  ASCabNew();

                                               centerCab =  ASCabNew();

                                               

                                               

                                                ASText  headText =  ASTextFromScriptText( "HeaderLeft" ,kASRomanScript);

                                                ASCabPutText(centerCab, "0" ,headText);

                                                ASCabPutText(centerCab, "1" ,headText);

                                                ASCabPutText(centerCab, "2" ,headText);

                                                ASCabPutCab(headerCab,kHeadFootCmdCenterCab,centerCab);

                                                ASCabPutCab(headFootCab,kHeadFootCmdHeadCab, headerCab);

                                               

                                               

                                                ASCabPutCab(params,kHeadFootCmdHeadFootCab,headFootCab);

                                               

                                               headFootCmdCab =  ASCabNew();

                                                ASCabPutBool(headFootCmdCab,kHeadFootCmdMakeOptional, true );

                                               

                                                ASCabPutCab(params,kHeadFootCmdHeadFootCmdCab,headFootCmdCab);

                                               

                                               cmdStatus =  AVCommandSetParams(cmd, params);

                               }

                                               

                HANDLER

                               cmdStatus =  kAVCommandInError;

                END_HANDLER

                if  (errorState ==  true ){

                                return ;

               }

               

                if  (params !=  NULL){

                                ASCabDestroy(params);

               }

                if  (config!=NULL){

                                ASCabDestroy(config);

               }

                               

                // we have set up the command, make sure there isn't a latent error

                // We're in silent mode, so we won't throw an alert dialog.

                if  (kAVCommandInError  == cmdStatus) {

                                AVCommandDestroy(cmd);

                                return ;

               }

                // we should be good to go at this point, execute the command.

               cmdStatus =  AVCommandExecute(cmd);

                // Release the resources associated with the command.

                AVCommandDestroy(cmd);


Viewing all articles
Browse latest Browse all 2571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>