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

How to get page count in C++

Community Beginner ,
May 03, 2020 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
TOPICS
How to , SDK

Views

1.2K

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 1 Correct answer

Enthusiast , May 04, 2020 May 04, 2020

Try this,

 

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

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

Votes

Translate

Translate
Enthusiast ,
May 04, 2020 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();

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

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 given works perfectly for me, what does "doesn't give any value after the compilation process gets completed" mean?

 

-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
Community Expert ,
May 06, 2020 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 )

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

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 Beginner ,
May 08, 2020 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

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 08, 2020 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

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 Beginner ,
May 08, 2020 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

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
Adobe Employee ,
Jun 11, 2020 Jun 11, 2020

Copy link to clipboard

Copied

LATEST

duplicate thread/spam, locked

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