Highlighted

How to get page count in C++

Community Beginner ,
May 03, 2020

Copy link to clipboard

Copied

Hi Professionals,

I don'tknow how to add the page count values in C++ . Please guide me ASAP

Rajendran

Try this,

 

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

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

TOPICS
How to, SDK

Views

728

Likes

Translate

Translate

Report

Report
This conversation has been locked.

How to get page count in C++

Community Beginner ,
May 03, 2020

Copy link to clipboard

Copied

Hi Professionals,

I don'tknow how to add the page count values in C++ . Please guide me ASAP

Rajendran

Try this,

 

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

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

TOPICS
How to, SDK

Views

729

Likes

Translate

Translate

Report

Report
May 03, 2020 0
Enthusiast ,
May 04, 2020

Copy link to clipboard

Copied

Try this,

 

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

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

Likes

Translate

Translate

Report

Report
May 04, 2020 0
Explorer ,
May 06, 2020

Copy link to clipboard

Copied

Hi,

I have used this following code and it compiles without any error but it doesn't give any value after the compilation process gets completed.

 

-Monisha

-Monisha

Likes

Translate

Translate

Report

Report
May 06, 2020 0
Adobe Community Professional ,
May 06, 2020

Copy link to clipboard

Copied

The code given works perfectly for me, what does "doesn't give any value after the compilation process gets completed" mean?

 

-Manan

Likes

Translate

Translate

Report

Report
May 06, 2020 0
Adobe Community Professional ,
May 06, 2020

Copy link to clipboard

Copied

Hi together,

I'm no SDK developer, just know my way arround in the ExtendScript DOM.

From that I know that the value of the page length can also obtained by a preference of the document:

documentPreferences.pagesPerDocument

 

Important note: pagesPerDocument is read/write

So it can be used at any time, when creating a document or even after a document is created, to change the number of document pages:

 

app.documents.add
(
{ documentPreferences : { pagesPerDocument : 10 } }
);

 

app.documents[0].documentPreferences.pagesPerDocument = 5 ;

 

And it's a very straight forward way to get the number of pages without asking the list of document pages:

 

var numberOfPagesInDoc = app.documents[0].documentPreferences.pagesPerDocument;

 

It should be possible to access the equivalent of pagesPerDocument with the SDK as well…

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

Report
May 06, 2020 1
Adobe Community Professional ,
May 06, 2020

Copy link to clipboard

Copied

Hi Uwe,

 

You are right, that would correspond to GetNumPagesPref method in IPageSetupPrefs interface on the kDocWorkspaceBoss boss class. The issue is not about finding a new way to do it, since the code shared already seems to work fine. I have tested the code and it seems to be working fine

 

-Manan

Likes

Translate

Translate

Report

Report
May 06, 2020 0
Community Beginner ,
May 08, 2020

Copy link to clipboard

Copied

I have run the code for the first time it provide the correct value but while running the code it provides an null value is this used method is correct or not. If it goes wrong please suggest me with the solution. But it gives the exact output as "2"

 

IDocument* doc = Utils<ILayoutUIUtils>()->GetFrontDocument();
if(doc)
{
InterfacePtr<IPageList> pagelist(doc, IID_IPAGELIST);
int32 count = pagelist->GetPageCount();
CAlert::WarningAlert("Values:"+count);

}

Now output recieved for me is attached for the reference

 

Rajendran_T_0-1588923738049.png

 

Regards,

Rajendran

Rajendran

Likes

Translate

Translate

Report

Report
May 08, 2020 0
Adobe Community Professional ,
May 08, 2020

Copy link to clipboard

Copied

I doubt the code you pasted is the one that you are running in your plugin, looking at it i suspect it will even compile. You can't join a string value with an integer as you have done inside CAlert. See screenshot below

Screenshot 2020-05-08 at 3.02.11 PM.png

 

 

 

 

 

 

 

Also your explanation is a bit confusing, you say you get 2 as the result but null as well. Do both these scenarios happen with the same document randomly? If not then what different do you do when the result is null? Are you able to debug your code?

 

Please answer every question i have asked for helping us help you, giving cryptic one line answers with a different code everytime which apparently is wrong and hence not working in the first place just wastes time all around.

 

-Manan

Likes

Translate

Translate

Report

Report
May 08, 2020 0
Community Beginner ,
May 08, 2020

Copy link to clipboard

Copied

Hi,

I have used this code in my plugin by that time it works and provide the null value and I have used two different document to display the page count value. but it display the null value. I have an doubt that how can I check the page count values using alertbox

 

Regards,

Rajendran 

Rajendran

Likes

Translate

Translate

Report

Report
May 08, 2020 0
Adobe Employee ,
Jun 11, 2020

Copy link to clipboard

Copied

duplicate thread/spam, locked

Likes

Translate

Translate

Report

Report
Jun 11, 2020 0