I'm trying to implement my conversion of DOCX to HTML and plain text. I use the org.docx4j.model.listnumbering.Emulator's getNumber() method to render numbered lists. When I use decimal numbering format everything is fine. But when using letters here is what I get:
- Code: Select all
a. One
b. Two
c. Three
d. Four
e. Five
f. Six
g. Seven
h. Eight
i. Nine
a9. Ten
aa. Eleven
ab. Twelve
ac. Thirteen
I've looked into the debug log and found that it internally uses this class: https://github.com/plutext/docx4j/blob/ ... etter.java
Here's the method:
- Code: Select all
public String format( int in ) {
String str = Integer.toString(in);
StringBuilder out = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
int dig = Character.digit(str.charAt(i), 36);
char cdig = Character.forDigit(dig + 9, 36);
log.debug(str.charAt(i) + " --> " + cdig);
out.append(cdig);
}
return out.toString();
}
It looks like it generates a letter for every digit of the number instead of generating for the whole number. So in alphabetic order 9th letter is "i" and 10th is "j", but instead of "j" we get "a9". "a" for the 1 and (for some reason) "9" for the 0.
Anyway, is it me doing something wrong, or is it really a bug? I'm attaching the example of input, output, the log and my code (not full, but I can send the full working app if you need).