Highlighted

Page count value in C++

Explorer ,
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

 

try this,

 

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

TOPICS
How to, SDK

Views

650

Likes

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

Page count value in C++

Explorer ,
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

 

try this,

 

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

TOPICS
How to, SDK

Views

651

Likes

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
May 06, 2020 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
May 06, 2020 0
Explorer ,
May 06, 2020

Copy link to clipboard

Copied

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

-Monisha

Likes

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
Reply
Loading...
May 06, 2020 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
May 06, 2020 0
Explorer ,
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

Likes

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
Reply
Loading...
May 06, 2020 0
Explorer ,
May 11, 2020

Copy link to clipboard

Copied

 

try this,

 

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

Nithu

Likes

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
Reply
Loading...
May 11, 2020 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
May 06, 2020 0
Explorer ,
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

Likes

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
Reply
Loading...
May 06, 2020 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
May 06, 2020 1