我正在使用Apache POI将doc转换为html。但脚注未转换为html。将doc文件转换为html时,doc文件中可用的脚注不存在于html文件/内容中。如何在转换后坚持这些脚注?
答案 0 :(得分:1)
这样做。我希望它能帮助你......!
public static void readMyDocument(String fileName){
POIFSFileSystem fs = null;
try {
fs = new POIFSFileSystem(new FileInputStream(fileName));
HWPFDocument doc = new HWPFDocument(fs);
/** Read the content **/
readParagraphs(doc);
int pageNumber=1;
/** We will try reading the header for page 1**/
readHeader(doc, pageNumber);
/** we will try reading the footer for page 1**/
readFooter(doc, pageNumber);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void readParagraphs(HWPFDocument doc) throws Exception{
WordExtractor we = new WordExtractor(doc);
/**Get the total number of paragraphs**/
String[] paragraphs = we.getParagraphText();
System.out.println("Total Paragraphs: "+paragraphs.length);
for (int i = 0; i < paragraphs.length; i++) {
System.out.println("Length of paragraph "+(i +1)+": "+ paragraphs[i].length());
System.out.println(paragraphs[i].toString());
}
}
public static void readHeader(HWPFDocument doc, int pageNumber){
HeaderStories headerStore = new HeaderStories( doc);
String header = headerStore.getHeader(pageNumber);
System.out.println("Header Is: "+header);
}
public static void readFooter(HWPFDocument doc, int pageNumber){
HeaderStories headerStore = new HeaderStories( doc);
String footer = headerStore.getFooter(pageNumber);
System.out.println("Footer Is: "+footer);
}