Skip to content

Commit

Permalink
add enableAnnotationRendering property support, default enableAnnotat…
Browse files Browse the repository at this point in the history
…ionRendering=true
  • Loading branch information
Wonday committed Sep 6, 2018
1 parent 5937dd0 commit 9b927cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ A4. Expo does not support native module. you can read more expo caveats [`here`]

### ChangeLog

v5.0.3
1. add enableAnnotationRendering property support, default enableAnnotationRendering=true

v5.0.2
1. fix file successfully download check

Expand Down Expand Up @@ -169,7 +172,7 @@ const styles = StyleSheet.create({
| enableAntialiasing | bool | true | improve rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch ||| <3.0 |
| enablePaging | bool | false | only show one page in screen ||| 5.0.1 |
| enableRTL | bool | false | scroll page as "page3, page2, page1" ||| 5.0.1 |
| enableAnnotationRendering | bool | false | enable rendering annotation ||| 5.0.3 |
| enableAnnotationRendering | bool | true | enable rendering annotation ||| 5.0.3 |
| onLoadProgress | function(percent) | null | callback when loading, return loading progress (0-1) ||| <3.0 |
| onLoadComplete | function(numberOfPages, path, {width, height}) | null | callback when pdf load completed, return total page count and pdf local/cache path ||| <3.0 |
| onPageChanged | function(page,numberOfPages) | null | callback when page changed ,return current page and total page count ||| <3.0 |
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class Pdf extends Component {
horizontal: false,
page: 1,
enableAntialiasing: true,
enableAnnotationRendering: false,
enableAnnotationRendering: true,
enablePaging: false,
enableRTL: false,
activityIndicatorProps: {color: '#009900', progressTintColor: '#009900'},
Expand Down
16 changes: 10 additions & 6 deletions ios/RCTPdf/RCTPdfView.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (instancetype)init
_horizontal = NO;
_enablePaging = NO;
_enableRTL = NO;
_enableAnnotationRendering = NO;
_enableAnnotationRendering = YES;
_fitPolicy = 2;
_spacing = 10;

Expand Down Expand Up @@ -141,10 +141,14 @@ - (void)didSetProps:(NSArray<NSString *> *)changedProps
}

if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"enableAnnotationRendering"])) {
int pageCount = _pdfDocument.pageCount;
for (int i=0; i<pageCount; i++) {
PDFPage *pdfPage = [_pdfDocument pageAtIndex:i];
pdfPage.displaysAnnotations = _enableAnnotationRendering;
if (!_enableAnnotationRendering) {
for (unsigned long i=0; i<_pdfView.document.pageCount; i++) {
PDFPage *pdfPage = [_pdfView.document pageAtIndex:i];
for (unsigned long j=0; j<pdfPage.annotations.count; j++) {
[pdfPage removeAnnotation:pdfPage.annotations[j]];
//pdfPage.annotations[j].shouldDisplay = _enableAnnotationRendering;
}
}
}
}

Expand Down Expand Up @@ -396,4 +400,4 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogni



@end
@end

0 comments on commit 9b927cf

Please sign in to comment.