Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 878a91a

Browse files
committed
Merge branch 'master' of https://github.com/usef/AndroidPdfViewer into usef-master
2 parents 4ee194a + 9d9472b commit 878a91a

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/PDFView.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@ public class PDFView extends SurfaceView {
265265
*/
266266
private boolean bestQuality = false;
267267

268+
/**
269+
* True if annotations should be rendered
270+
* False otherwise
271+
*/
272+
private boolean annotationRendering = false;
273+
268274
/**
269275
* Storing already opened pages. Used form optimizing Pdfium calls
270276
*/
@@ -677,7 +683,7 @@ private int loadPage(final int userPage, final int nbOfPartsLoadable) {
677683
renderingAsyncTask.addRenderingTask(userPage, documentPage, //
678684
(int) (optimalPageWidth * Constants.THUMBNAIL_RATIO), //
679685
(int) (optimalPageHeight * Constants.THUMBNAIL_RATIO), //
680-
new RectF(0, 0, 1, 1), true, 0, bestQuality);
686+
new RectF(0, 0, 1, 1), true, 0, bestQuality, annotationRendering);
681687
}
682688

683689
// When we want to render a 256x256 bloc, we also need to provide
@@ -757,7 +763,7 @@ public boolean onLoop(int row, int col) {
757763
// If not already in cache, register the rendering
758764
// task for further execution.
759765
renderingAsyncTask.addRenderingTask(userPage, documentPageFinal, //
760-
renderWidth, renderHeight, pageRelativeBounds, false, nbItemTreated, bestQuality);
766+
renderWidth, renderHeight, pageRelativeBounds, false, nbItemTreated, bestQuality, annotationRendering);
761767
}
762768

763769
}
@@ -1174,6 +1180,10 @@ public void useBestQuality(boolean bestQuality) {
11741180
this.bestQuality = bestQuality;
11751181
}
11761182

1183+
public void enableAnnotationRendering(boolean annotationRendering) {
1184+
this.annotationRendering = annotationRendering;
1185+
}
1186+
11771187
public PdfDocument.Meta getDocumentMeta() {
11781188
if(pdfDocument == null) {
11791189
return null;
@@ -1254,6 +1264,8 @@ public class Configurator {
12541264

12551265
private boolean swipeVertical = false;
12561266

1267+
private boolean annotationRendering = false;
1268+
12571269
private int maskColor = Color.BLACK;
12581270

12591271
private int maskAlpha = Constants.MASK_ALPHA;
@@ -1280,6 +1292,11 @@ public Configurator enableDoubletap(boolean enableDoubletap) {
12801292
return this;
12811293
}
12821294

1295+
public Configurator enableAnnotationRendering(boolean annotationRendering) {
1296+
this.annotationRendering = annotationRendering;
1297+
return this;
1298+
}
1299+
12831300
public Configurator onDraw(OnDrawListener onDrawListener) {
12841301
this.onDrawListener = onDrawListener;
12851302
return this;
@@ -1335,6 +1352,7 @@ public void load() {
13351352
PDFView.this.setDefaultPage(defaultPage);
13361353
PDFView.this.setUserWantsMinimap(showMinimap);
13371354
PDFView.this.setSwipeVertical(swipeVertical);
1355+
PDFView.this.enableAnnotationRendering(annotationRendering);
13381356
PDFView.this.dragPinchManager.setSwipeVertical(swipeVertical);
13391357
PDFView.this.maskPaint = new Paint();
13401358
PDFView.this.maskPaint.setColor(maskColor);

android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/RenderingAsyncTask.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public RenderingAsyncTask(PDFView pdfView, PdfiumCore pdfiumCore, PdfDocument pd
4747
this.pdfDocument = pdfDocument;
4848
}
4949

50-
public void addRenderingTask(int userPage, int page, float width, float height, RectF bounds, boolean thumbnail, int cacheOrder, boolean bestQuality) {
51-
RenderingTask task = new RenderingTask(width, height, bounds, userPage, page, thumbnail, cacheOrder, bestQuality);
50+
public void addRenderingTask(int userPage, int page, float width, float height, RectF bounds, boolean thumbnail, int cacheOrder, boolean bestQuality, boolean annotationRendering) {
51+
RenderingTask task = new RenderingTask(width, height, bounds, userPage, page, thumbnail, cacheOrder, bestQuality, annotationRendering);
5252
renderingTasks.add(task);
5353
wakeUp();
5454
}
@@ -107,7 +107,7 @@ private PagePart proceed(RenderingTask renderingTask) {
107107

108108
pdfiumCore.renderPageBitmap(pdfDocument, render, renderingTask.page,
109109
roundedRenderBounds.left, roundedRenderBounds.top,
110-
roundedRenderBounds.width(), roundedRenderBounds.height());
110+
roundedRenderBounds.width(), roundedRenderBounds.height(), renderingTask.annotationRendering);
111111

112112
if (!renderingTask.bestQuality) {
113113
Bitmap cpy = render.copy(Bitmap.Config.RGB_565, false);
@@ -157,7 +157,9 @@ private class RenderingTask {
157157

158158
boolean bestQuality;
159159

160-
public RenderingTask(float width, float height, RectF bounds, int userPage, int page, boolean thumbnail, int cacheOrder, boolean bestQuality) {
160+
boolean annotationRendering;
161+
162+
public RenderingTask(float width, float height, RectF bounds, int userPage, int page, boolean thumbnail, int cacheOrder, boolean bestQuality, boolean annotationRendering) {
161163
super();
162164
this.page = page;
163165
this.width = width;
@@ -167,6 +169,7 @@ public RenderingTask(float width, float height, RectF bounds, int userPage, int
167169
this.thumbnail = thumbnail;
168170
this.cacheOrder = cacheOrder;
169171
this.bestQuality = bestQuality;
172+
this.annotationRendering = annotationRendering;
170173
}
171174

172175
}

sample/src/main/java/com/github/barteksc/sample/PDFViewActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ private void displayFromAsset(String assetFileName) {
8888
.onPageChange(this)
8989
.swipeVertical(true)
9090
.showMinimap(false)
91+
.enableAnnotationRendering(true)
9192
.onLoad(this)
9293
.load();
9394
}
@@ -100,6 +101,7 @@ private void displayFromUri(Uri uri) {
100101
.onPageChange(this)
101102
.swipeVertical(true)
102103
.showMinimap(false)
104+
.enableAnnotationRendering(true)
103105
.onLoad(this)
104106
.load();
105107
}

0 commit comments

Comments
 (0)