pdf2htmlEX文本选择问题

时间:2016-09-22 06:50:30

标签: pdf2htmlex

我已使用pdf2htmlEX将pdf转换为html。选择多行时,当光标在两行之间时,选择会向上跳跃。请帮助解决这个问题。

enter image description here

enter image description here

这里已经提出了问题https://github.com/coolwanglu/pdf2htmlEX/issues/62,但解决方案并没有解决问题。需要帮助来解决这个问题。

1 个答案:

答案 0 :(得分:0)

作为解决方法,我创建了以下样式:

.t {
    /* making selection to behave nicer when selecting text between multiple text lines (to avoid element gaps which can cause weird selection behavior) */
    padding-bottom: 100px;
    margin-bottom: -25px;

    /* making selection to behave nicer when selecting text between multiple columns (useful for pages with 2 or more text columns) */
    padding-right: 2000px;
}

问题是所有文本元素都已绝对定位,并且每当鼠标(在选择期间)离开文本元素时,它都会在 page元素上触发鼠标事件(这会导致从中选择文本页面的起点到起点),直到到达其他文本元素。

这种样式/解决方法可以“填补”这些空白,使鼠标永远不会到达页面元素。

文档应该看起来一样。


编辑:请注意,此解决方案依赖于正确的DOM结构(文本元素是有序的)。在某些情况下,文本可能变得无法选择(例如,当页面包含2个文本列并且第一个文本块实际上作为DOM中的最后一个子元素放置时)。

如果遇到此类问题,请尝试调整值以使其恰好适合您的文档,如下所示:

.t {
    /* making selection to behave nicer when selecting text between multiple text lines (to avoid element gaps which can cause weird selection behavior) */
    padding-bottom: 40px;
    margin-bottom: -10px;

    /* making selection to behave nicer when selecting text between multiple columns (useful for pages with 2 or more text columns) */
    padding-right: 0px;
}

选择可能会到处跳动(再次取决于文档结构和使用的值),但是与原始状态相比,它会好很多。