>>One possible workaround: Some editors, like OpenOffice, write out a >>soft page using the <text:soft-page-break> element.
We are using OpenOffice 3.3.0 and do not see these tags in our docs. I am guessing that is because we originally imported these from Word. I do see this in the content.xml: <office:text text:use-soft-page-breaks= "true"> >> What I need to do is locate a Bookmark in an ODT (done), and record what >> page this certain Bookmark resides in. (Needed for page insertion later). >> I originally thought I could parse the <text:page-number> value, but this >> value is not tied to the "current page". >> >Another option, and a cleaner one if it solves your problem, is to use >a page number field: > http://incubator.apache.org/odftoolkit/simple/document/javadoc/org/odftoolkit/simple/common/field/Fields.html#createNextPageNumberField%28org.odftoolkit.odfdom.pkg.OdfElement%29 >Fields are calculated at runtime, so they always reflect the current >layout. They are the preferred way to refer to a page number in the >text of an ODF document. See from my note above that I am using page numbers in our footer. There are two instances of this in the styles.xml, and they both are set to the same value. The doc originally had two pages. My bookmark ends up on page three after text is inserted into the odt doc. However, there is no change to page-number until it is rendered in a viewer. ...<text:page-number text:select-page="current">2 </text:page-number></text:p></style:footer> Creating a page-number as your link suggests results in an empty page number field. I need to determine what page my bookmark is currently on. <text:page-number style:num-format="" text:select-page="current"></text:page-number> Thanks for your response. Looks like I will have to find another way. Kevin Skelton This message is intended for use only by the person(s) addressed above and may contain privileged and confidential information. Disclosure or use of this message by any other person is strictly prohibited. If this message is received in error, please notify the sender immediately and delete this message. From: Rob Weir <[email protected]> To: [email protected] Date: 05/09/2012 07:31 AM Subject: Re: Retrieve current "Page Number" from an ODT On Tue, May 8, 2012 at 3:53 PM, Kevin Skelton <[email protected]> wrote: > I understand that there is no true concept of a page number within an ODT, > and I read the prior thread on this concept. Correct. Layout is done at runtime in an editor. Page breaks are sensitive to things line font metrics, line breaking algorithms, "widow and orphan" calculations and other details of layout. > However, I am wondering if there have been any enhancements to the API, or > other tricks that could retrieve a relative page number on which an item > resides. > In the general case, no. You would need to simulate the layout of the document, and that would be very difficult. One possible workaround: Some editors, like OpenOffice, write out a soft page using the <text:soft-page-break> element. The intention of this is to indicate where the page breaks were at the last time the document was saved from the editor. This is useful information to some assistive technologies. For example, a blind person can follow along in a meeting reviewing a document with a reader, and when someone says, "Now switch to page 11," they can follow. So you might be able to scan for the soft page breaks and from those determine the page numbers, as of the the last time the document was saved. Note: if you programmatically manipulate the document, with ODF Toolkit, the soft page breaks could be misplaced. For example, if you insert a lot of new text. > What I need to do is locate a Bookmark in an ODT (done), and record what > page this certain Bookmark resides in. (Needed for page insertion later). > I originally thought I could parse the <text:page-number> value, but this > value is not tied to the "current page". > Another option, and a cleaner one if it solves your problem, is to use a page number field: http://incubator.apache.org/odftoolkit/simple/document/javadoc/org/odftoolkit/simple/common/field/Fields.html#createNextPageNumberField%28org.odftoolkit.odfdom.pkg.OdfElement%29 Fields are calculated at runtime, so they always reflect the current layout. They are the preferred way to refer to a page number in the text of an ODF document. Regards, -Rob > I do not see a way to do this. If this can/cannot be done, please let me > know. > > Thanks, > > Kevin Skelton > > This message is intended for use only by the person(s) addressed above and > may contain privileged and confidential information. Disclosure or use of > this message by any other person is strictly prohibited. If this message > is received in error, please notify the sender immediately and delete this > message.
