【问题标题】:Attach icon to link on MuPDF将图标附加到 MuPDF 上的链接
【发布时间】:2015-09-10 09:18:13
【问题描述】:

我在我的 android 项目中使用 MuPDF 库。我清楚地实现了它,它工作正常。在我的 PDF 中有很多导航浏览器的链接,但用户无法弄清楚它们。我想在项目有导航链接的布局上添加一个图标。我怎样才能做到这一点? 感谢您的帮助。

【问题讨论】:

    标签: android mupdf


    【解决方案1】:

    我找到了办法。 在 PageView.java 类中,有一个方法叫**setPage(int page, PointF size)** 有一个块在高亮链接上绘制内容。

    if (!mIsBlank && mLinks != null && mHighlightLinks) {
                        paint.setStrokeWidth(2);
                        for (LinkInfo link : mLinks) {
                            RectF rectfa = new RectF((link.rect.left - 2) * scale, (link.rect.top - 2) * scale, (link.rect.right + 2) * scale, (link.rect.bottom + 2) * scale);
                            paint.setStyle(Paint.Style.FILL);
                            paint.setColor(LINK_COLOR);
                            canvas.drawRoundRect(rectfa, 3 * scale, 3 * scale, paint);
    
                            paint.setStyle(Paint.Style.STROKE);
                            paint.setColor(HIGHLIGHT_COLOR);
                            canvas.drawRoundRect(rectfa, 3 * scale, 3 * scale, paint);
    
                            int left = (int) ((link.rect.left - 2) * scale);
                            int right = (int) ((link.rect.right + 2) * scale);
                            int top = (int) ((link.rect.top - 2) * scale);
                            int bottom = (int) ((link.rect.bottom + 2) * scale);
    
                            Rect dstRectForRender = new Rect(right - bitmap.getWidth(), top, right, top + bitmap.getHeight());
                            canvas.drawBitmap(bitmap, null, dstRectForRender, null);// I draw my bitmap on here.
                        }
                    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-24
      • 2011-10-01
      • 2010-12-27
      • 1970-01-01
      • 2020-10-26
      • 1970-01-01
      • 1970-01-01
      • 2017-07-22
      相关资源
      最近更新 更多