• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Page count value in C++

Participant ,
May 06, 2020 May 06, 2020

Copy link to clipboard

Copied

Hi,

I have used the page count code in C++ for developing our own plugin. But it doesn't provide the count value after building the plugin. Can someone guide on me. For the reference I have attached the code.

 

IDocument* document1 = GetExecutionContextSession()->GetActiveContext()->GetContextDocument();
if (document1 == nil)
{
aWarning = CAlert::ModalAlert("Please open the document. No active document", "Ok", "Continue", kNullString, 1, CAlert::eWarningIcon);

break;
}
else
{
IDocument* doc = Utils<ILayoutUIUtils>()->GetFrontDocument();

InterfacePtr<IPageList> pagelist(doc, IID_IPAGELIST);
int32 count = pagelist->GetPageCount();
}

-Monisha
TOPICS
How to , SDK

Views

866

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 06, 2020 May 06, 2020

HI,

 

I don't think there is a need to get the IDocument twice, why can you not use the first one you get?



Regards

Malcolm

Votes

Translate

Translate
Explorer , May 11, 2020 May 11, 2020

 

try this,

 

IDocument* doc = Utils<ILayoutUIUtils>()->GetFrontDocument();
if(doc)
{
InterfacePtr<IPageList> pagelist(doc, IID_IPAGELIST);
int32 count = pagelist->GetPageCount();
}

Votes

Translate

Translate
Community Expert ,
May 06, 2020 May 06, 2020

Copy link to clipboard

Copied

What do you mean by it does not give count value after building? Can you be a bit more specific? Does the code compile? Do you get a crash at runtime? Is the value you get in the count variable wrong, if yes what the value is and what do you expect?

There is an answer market correct for this same question, it the poster your collegue?

https://community.adobe.com/t5/indesign/how-to-get-page-count-in-c/td-p/11102481

 

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2020 May 06, 2020

Copy link to clipboard

Copied

the code get compiled but it doesnot produce any page count values

-Monisha

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2020 May 06, 2020

Copy link to clipboard

Copied

HI,

 

I don't think there is a need to get the IDocument twice, why can you not use the first one you get?



Regards

Malcolm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2020 May 06, 2020

Copy link to clipboard

Copied

Hi,

I have removed the IDocument which is repeated twice but I can't get the value is any issue in calling the page count values.

 

-Monisha

-Monisha

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

LATEST

 

try this,

 

IDocument* doc = Utils<ILayoutUIUtils>()->GetFrontDocument();
if(doc)
{
InterfacePtr<IPageList> pagelist(doc, IID_IPAGELIST);
int32 count = pagelist->GetPageCount();
}

Nithu

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2020 May 06, 2020

Copy link to clipboard

Copied

The code works just fine for me and gives back the correct page number, except ofcourse the pointers given by Malcolm need to be taken care of

As i asked you need to give proper information to make us help, why do you say the value you get it wrong, you did not reply on that

 

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2020 May 06, 2020

Copy link to clipboard

Copied

Hi,

I have not recieved any values after the compilation and that is the query I have been asking for..And after fetching the data it must displaced in the editbox.

 

-Monisha

-Monisha

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2020 May 06, 2020

Copy link to clipboard

Copied

Sorry to ask but are you even a regular developer? You choice of words point otherwise. You will get values after the code runs not after compilation as you have been stressing again and again.

Secondly there is no such thing as no value, if a method signature has a return type defined then it has to return a value of that type, no execptions to this rule. So if your GetPageCount method is getting called then count variable will definitely have a value, no matter what. The value can be wrong as per your assessment, that is a different thing but no value is out of question.

 

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines