Apache的POI:从XWPFParagraph实例找回页码? [英] Apache POI: Retrieve page number from XWPFParagraph instance?

查看:797
本文介绍了Apache的POI:从XWPFParagraph实例找回页码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遍历XWPFParagraph实例从XWPTDocument未来实例(使用getParagraphs()方法)有没有一种方法来检索的页面数,其中每个段落距离 XWPFParagraph 实例?

I am iterating over XWPFParagraph instances coming from an XWPTDocument instance (using the "getParagraphs()" method) Is there a way to retrieve the page numbers where each paragraph is located from the XWPFParagraph instances?

推荐答案

要最终把<一个href=\"http://stackoverflow.com/questions/30478540/apache-poi-retrieve-page-number-from-xwpfparagraph-instance#comment49040975_30478540\">Gagravarr's评论到一个合适的答案:否,这是不可能的

To eventually turn Gagravarr's comment into a proper answer: No, this is not possible.

这样做需要一个成熟的Word渲染引擎(即微软Word本身),即使这样,你也不能绝对肯定,他们发生了曾经创建的文件时,是分页总是会发生在完全相同的位置(认为:。缺少的字体,丢失照片,为消失的文字和/或修订标记,不同的打印机页边距等不同的显示选项)

Doing so would require a full-blown Word rendering engine (i.e. MS Word itself) and even then you cannot be absolutely sure that page breaks will always occur at exactly those positions where they happened to be when the file was once created (think: missing fonts, missing pictures, different display options for vanished text and/or revision marking, different printer margins, etc.).

所以,声称在一个Word文件中的一些内容是对某一页Y于某一线X实际上前presses Word文件格式的根本误解。是根本不存在的的的想法和的在那里。它的所有有关的运行 RESP。的范围

So claiming that some content in a Word file is on a certain line X on a certain page Y actually expresses a fundamental misunderstanding of the Word file format. There is simply no notion of line and page in there. It's all about runs resp. ranges.

在换句话说:只有在与MS Word中打开这样的文件将这些内容呈现到各行/页。与此渲染未predictable到一定程度的行为。

In other words: Only upon opening such a file with MS Word will those contents be rendered onto individual lines / pages. And the behavior of this renderer unpredictable to a certain extent.

这篇关于Apache的POI:从XWPFParagraph实例找回页码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆