So far, I have found that the bookmarks are all contained within what is
called the table stream. If you want to have a look, try running this code;
File file = null;
FileInputStream fis = null;
HWPFDocument document = null;
try {
file = new File("...your file name.......");
fis = new FileInputStream(file);
document = new HWPFDocument(fis);
String tableStreamContents = new
String(document.getTableStream(), "UTF-16LE");
for(int i = 0; i < tableStreamContents.length(); i++) {
char aChar = tableStreamContents.charAt(i);
System.out.println("Character: " + aChar + ", Hex: " +
Integer.toHexString(aChar));
}
System.setOut(sysOut);
}
catch(Exception ex) {
ex.printStackTrace(System.out);
}
finally {
if(fis != null) {
try {
fis.close();
fis = null;
}
catch(Exception ex) {
// I G N O R E
}
}
}
and you should see a very long output where each character is printed
accompanied by it's hex value. Scroll down far enough and you should find
the bookmarks.
The next step is to try and identify the character sequences that indicate
the beginning of the list of bookmarks, marks it's end and then, finally,
separates each bookmark from it's neighbour.
You may have to change the character encoding, which is currently hardcoded
to UTF-16LE, if the output you see looks to be just rubbish. Finally, I am
sorry if this all looks a little messy; HWPF is still very much in
development and it is quite often the case that work like this advances the
API one step further.
If I make any more progress, I will post again.
Yours
Mark B
Fernando Antonio Prado wrote:
>
>
> Hi there. I've just subscribed here so this is my first email. I searched
> the POI site but couldn't find the answer to may problem. I've just
> downloaded the most recent version of HWPF and I1d like to know if there's
> any way I can get the bookmarks of a word document. I'll be very pleased
> with your help.. Thx!!
>
> _________________________________________________________________
> Com o Windows Live, vocĂȘ pode organizar, editar e compartilhar suas fotos.
> http://www.microsoft.com/brasil/windows/windowslive/products/photo-gallery-edit.aspx
>
--
View this message in context:
http://www.nabble.com/Bookmarks-on-word-documents-tp24573916p24586415.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]