I have the below code which returns the total number of pages in my document. I can call this with javascript soapplet.getNumberOfPages()
I want to do a similar method that will return just the PageNumber. I have found this class com.sun.star.text.TextField.PageNumber but I cannot figure out how to return a string of the PageNumber. In javascript then I will be able to search the document for a certain string and depending where the string is found I will be able to determine the page number on that document where string exists. I can then tell the printer to print this page from the headed paper tray. I've googled for a day or two and can't find anything. Thanks
public int getNumberOfPages()
{
XController xController = OODocument.getCurrentDocument().getXFrame().getController();
XTextViewCursorSupplier supTextViewCursor =
(XTextViewCursorSupplier) UnoRuntime.queryInterface(
XTextViewCursorSupplier.class, xController);
XTextViewCursor curTextView = supTextViewCursor.getViewCursor();
XPageCursor curPage =
(XPageCursor) UnoRuntime.queryInterface(
XPageCursor.class, curTextView);
curPage.jumpToLastPage();
System.out.println("pages = " + curPage.getPage());
return curPage.getPage();
}
I'm rethinking this now and wondering if its possible in javascript to find the string and then to return the page number that string is on. code I have is:
if(printOnPlainPaper == true) {
if(soApplet.isConnected())
{
soDoc = soDoc + soApplet.getEncodedHtmlDocument( null );
if(soDoc.indexOf("zzzzz"))
{
alert("trueeeee");
}
else
{
soApplet.printDocument(PLAIN_PAPER, "1-"); // print page 1 to plain paper printer
}
}
//soApplet.printDocument(PLAIN_PAPER, "1-"); // print page 1 to plain paper printer
}
It can find the string but then how do I get it to tell me the page number its on?
Thanks