的itext標籤(未itext7),我假設你正在使用的iText 5.5.x.
的PdfWriter
類提供返回當前垂直位置的方法:
/**
* Use this method to get the current vertical page position.
* @param ensureNewLine Tells whether a new line shall be enforced. This may cause side effects
* for elements that do not terminate the lines they've started because those lines will get
* terminated.
* @return The current vertical page position.
*/
public float getVerticalPosition(final boolean ensureNewLine)
因此,以檢索當前頁上的剩餘的主要內容空間的垂直範圍,則僅需要檢索這個垂直位置值並減去底部頁邊距的y位置(可使用Document
方法bottom()
檢索該位置)。
您獲得的值是默認的用戶空間單位(它依次默認爲1/72英寸)。
行的數量顯然取決於您想要在這些行上使用的字體和其他參數(字體大小,前導,...)。
來源
2017-02-13 13:13:05
mkl