gpt4 book ai didi

java - Apache POI 用于将文档转换为带脚注的 html

转载 作者:行者123 更新时间:2023-12-01 11:34:03 24 4
gpt4 key购买 nike

我正在使用 Apache POI 将 doc 转换为 html。但脚注未转换为 html。将 doc 文件转换为 html 时,doc 文件中可用的脚注不存在于 html 文件/内容中。转换后如何保留这些脚注?

最佳答案

这样做。我希望它能帮助你..!

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);

}

关于java - Apache POI 用于将文档转换为带脚注的 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30181468/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com