6 Replies Latest reply: Feb 29, 2012 3:17 PM by Norio Kawamura RSS

    How to change the Document's Page size from plugin

    suren_tringer

      Hi friends,

       

      I am try to change the document's page size from custom plugin. Any advise ? Any keywords? Please....

        • 1. Re: How to change the Document's Page size from plugin
          Norio Kawamura Community Member

          I am using kSetPageSizeCmdBoss.

          • 2. Re: How to change the Document's Page size from plugin
            suren_tringer

            Hi Norio ,thanks for your reply

            Infact I am new to plugin development. Can you tell me how to use kSetPageSizeCmdBoss and how to use interfaceptr for IDocSetupCmdData.

            • 3. Re: How to change the Document's Page size from plugin
              Norio Kawamura Community Member

              Refer BscMEInvertFacade.cpp in sdksamples/basicme.

              • 4. Re: How to change the Document's Page size from plugin
                suren_tringer

                Hi Norio, i am not able to get complete idea with that code .Still i dont know how to get current document UID.

                 

                InterfacePtr<ICommand> cmd(CmdUtils::CreateCommand(kSetPageSetupPrefsCmdBoss));

                    if(cmd == nil)

                    {

                        ASSERT_FAIL("BscMEInvertFacade::SetDocumentPageBinding - cmd is nil");

                        return;

                    }

                 

                    InterfacePtr<IDocSetupCmdData> cmdData(cmd, IID_IDOCSETUPCMDDATA);

                    if(cmdData == nil)

                    {

                          return;     

                    }

                Here  i struck up with get refrence of database

                ...

                ...

                InterfacePtr<IDocument> document(db, db->GetRootUID(), UseDefaultIID());

                if (document != nil)

                   InterfacePtr<IPageSetupPrefs> pageSetupPrefs(document->GetDocWorkSpace(), UseDefaultIID());

                   if(pageSetupPrefs == nil)

                    {

                     return;

                  }

                    PMRect rect(0,0,1024,768);

                    cmdData->SetDocument(::GetUIDRef(document));

                    cmdData->SetPageSize(rect);

                          //    OR

                //cmdData->Set(::GetUIDRef(doc),

                //                    pageSetupPrefs->GetPageSizePref(),

                //                    pageSetupPrefs->GetNumPagesPref(),

                //                    pageSetupPrefs->GetPagesPerSpreadPref(),

                  //                   pageSetupPrefs->GetWideOrientationPref(),

                  //                   pageBinding);

                    CmdUtils::ProcessCommand(cmd);

                 

                can you point out the mistakes . i am just learning the basics. can you suggest me some idea to learn indesgn sdk. Still i dont get concrete idea about plugin developement .eg..how to create instance or get refrence for a boss .

                Can you please help me .

                • 5. Re: How to change the Document's Page size from plugin
                  suren_tringer

                  Hi Norio, i found a way to set page size.    

                   

                    thanks for your reply . please tell me if there is any other best way , 

                     

                     InterfacePtr<IApplication> application(GetExecutionContextSession()->QueryApplication());

                      InterfacePtr<IDocumentList> documentList(application->QueryDocumentList());

                      for (int32 i = 0; i < documentList->GetDocCount(); i++) {

                          IDocument* document = documentList->GetNthDoc(i);

                          InterfacePtr<ICommand> cmd(CmdUtils::CreateCommand(kSetPageSetupPrefsCmdBoss));

                          if(cmd == nil)

                          {

                              ASSERT_FAIL("BscMEInvertFacade::SetDocumentPageBinding - cmd is nil");

                              return;

                          }

                         

                          InterfacePtr<IDocSetupCmdData> cmdData(cmd, IID_IDOCSETUPCMDDATA);

                          if(cmdData == nil)

                          {

                                 return:

                          }

                   

                          PMRect rect(0,0,100,100);

                          cmdData->Set(::GetUIDRef(document),

                                       rect,

                                       1,

                                      1,

                                      kTrue,

                                       kFalse);

                         

                          CmdUtils::ProcessCommand(cmd);

                  • 6. Re: How to change the Document's Page size from plugin
                    Norio Kawamura Community Member

                    If you create a kUIPlugIn, try,

                    IDocument* doc = Utils<ILayoutUIUtils>()->GetFrontDocument();

                     

                    InterfacePtr<ICommand> cmd(CmdUtils::CreateCommand(kSetPageSizeCmdBoss));

                    InterfacePtr<IDocSetupCmdData> cmdData(cmd, IID_IDOCSETUPCMDDATA);

                    PMRect pageRect(0, 0, width, height);

                    cmdData->SetDocument(::GetUIDRef(doc));

                    cmdData->SetPageSize(pageRect);

                    /*

                    // for kSetPageSetupPrefsCmdBoss

                    InterfacePtr<IPageSetupPrefs> pageSetupPrefs(doc->GetDocWorkSpace(), UseDefaultIID());

                    cmdData->Set(::GetUIDRef(doc),

                              pageRect,

                              pageSetupPrefs->GetNumPagesPref(),

                              pageSetupPrefs->GetPagesPerSpreadPref(),

                              pageSetupPrefs->GetWideOrientationPref(),

                              pageSetupPrefs->GetPageBindingPref());

                    */

                    CmdUtils::ProcessCommand(cmd);