2015-09-10 108 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. 
        } 
       }