2015-09-10 72 views
0

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

回答

0

我找到了一种方法。 在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. 
        } 
       }