【问题标题】:pdf2htmlEX text selection issuepdf2htmlEX 文本选择问题
【发布时间】:2017-01-30 14:56:34
【问题描述】:

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

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

【问题讨论】:

    标签: pdf2htmlex


    【解决方案1】:

    作为解决方法,我创建了这种样式:

    .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;
    }
    

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

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

    文档应该看起来一样。


    编辑:请注意,此解决方案依赖于正确的 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;
    }
    

    选择可能会跳来跳去(同样取决于文档结构和使用的值),但与原始状态相比仍然会好很多。

    【讨论】:

      猜你喜欢
      • 2011-03-29
      • 2018-01-06
      • 1970-01-01
      • 2016-11-30
      • 1970-01-01
      • 2021-12-25
      • 2020-03-22
      • 2015-01-22
      • 2021-06-12
      相关资源
      最近更新 更多