Question

I am receiving page numbers from a test box widget and it is of type PMString. I need to convert it into int32 to pass to my createDocument function.

Is there a suitable function available anywhere which can do that type conversion ?

Was it helpful?

Solution

First, a literal answer: Instead of a generic text box widget (TextEditBoxWidget), you can use an integer edit box: IntEditBoxWidget.

Longer version:

This assumes your "page numbers" are entered as numbers. Note that (1) internal references to pages start at 0, so for a page number "1" you need to subtract 1; and (2) if your document starts at a number other than '1', you need to subtract this instead. (Come to think of it, (2) is a generalization of (1).)

There appears to be no general widget for "any valid page number" (after checking the CS6 SDK Documentation). For 'any' page number, in all formats InDesign supports, you indeed need a TextEditBoxWidget (which has the description "Displays values that are strictly textual, or where you want to parse a value in your own code") as well as code to parse it.

InDesign has an extensive set of page numbering options: optionally section numbering, and several (8 or so) different ways of representing a page number. The Jump To Page dialog and the Export to PDF dialog supports this, as well as 'absolute' numbering: "+5" will always go to the 5th page, regardless of section numbering settings. However, this option is not mentioned in so many words in the documentation. Presumably the easiest way to implement it is to loop over your pages and ask for its current Page Number string, and compare this to your input.

OTHER TIPS

PMString has a function to do that

int32 GetAsNumber()

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top