Skip to content

Commit 56deb32

Browse files
author
sekar_neutrinos
committed
toolbar position fixed using status bar height
1 parent dee4256 commit 56deb32

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This plugin allows you to view pdf file base64 using ios native library PDFKit a
44

55
## Supported Platforms ##
66

7-
* iOS 11+
8-
* Cordova/Phonegap >=7.1.0
7+
* iOS 13+
8+
* Cordova/Phonegap >=10.0.0
99

1010
## Installation ##
1111
```bash

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-pdf-viewer-ios",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"description": "cordova pdf viewer plugin",
55
"cordova": {
66
"id": "cordova-plugin-pdf-viewer-ios",
@@ -39,8 +39,8 @@
3939
"engines": {
4040
"cordovaDependencies": {
4141
"1.0.0": {
42-
"cordova": ">=7.1.0",
43-
"cordova-ios": ">=4.5.1"
42+
"cordova": ">=10.0.0",
43+
"cordova-ios": ">=6.0.0"
4444
}
4545
}
4646
},

plugin.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
id="cordova-plugin-pdf-viewer-ios"
5-
version="1.0.8">
5+
version="1.0.9">
66
<engines>
7-
<engine name="cordova" version=">=7.1.0" />
8-
<engine name="cordova-ios" version=">=4.5.1" />
7+
<engine name="cordova" version=">=10.0.0" />
8+
<engine name="cordova-ios" version=">=6.0.0" />
99
</engines>
1010
<name>PDFViewer</name>
1111
<js-module name="PDFViewer" src="www/PDFViewer.js">

src/ios/PDFViewer.m

+15-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ - (void)viewPDF:(CDVInvokedUrlCommand*)command
2626

2727
self.pdfDocument = [[PDFDocument alloc] initWithData:[self getBase64Data]];
2828

29-
self.pdfWebview = [[WKWebView alloc] initWithFrame: self.webView.bounds];
29+
/* Get status bar height if visible */
30+
UIStatusBarManager *manager = [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager;
31+
CGFloat height = 0;
32+
if(!manager.statusBarHidden) {
33+
height = manager.statusBarFrame.size.height;
34+
}
35+
36+
self.pdfWebview = [[WKWebView alloc] initWithFrame: CGRectMake(0, height, self.webView.bounds.size.width,self.webView.bounds.size.height - height)];
3037

31-
[self setToolbar];
38+
UIToolbar *toolbar = [self setToolbar];
3239

33-
self.pdfView = [[PDFView alloc] initWithFrame:CGRectMake(0, 50, self.pdfWebview.bounds.size.width, self.pdfWebview.bounds.size.height - 50)];
40+
self.pdfView = [[PDFView alloc] initWithFrame:CGRectMake(0, toolbar.bounds.size.height, self.pdfWebview.bounds.size.width, self.pdfWebview.bounds.size.height - toolbar.bounds.size.height)];
3441
self.pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
3542
self.pdfView.displayMode = [mode integerValue];
3643
self.pdfView.displayDirection = [direction isEqual: @"vertical"] ? kPDFDisplayDirectionVertical : kPDFDisplayDirectionHorizontal;
@@ -156,7 +163,7 @@ -(UIColor *)colorWithHexString:(NSString *)str_HEX alpha:(CGFloat)alpha_range{
156163
return [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:alpha_range];
157164
}
158165

159-
-(void)setToolbar {
166+
-(UIToolbar *)setToolbar {
160167

161168
NSString* toolbarColour = [self.command.arguments objectAtIndex:5];
162169
NSString* doneBtnColour = [self.command.arguments objectAtIndex:6];
@@ -244,7 +251,8 @@ -(void)setToolbar {
244251
[toolbar setItems: items];
245252
[self.pdfWebview addSubview:toolbar];
246253
[self.pdfWebview bringSubviewToFront: toolbar];
247-
254+
255+
return toolbar;
248256
}
249257

250258
-(NSString*)getPath {
@@ -351,7 +359,7 @@ -(void)shareFn:(UIButton* _Nullable)sender base64:(NSData *)data shareText:(NSSt
351359
activityViewControntroller.popoverPresentationController.sourceView = sender;
352360
activityViewControntroller.popoverPresentationController.sourceRect = sender.bounds;
353361
} else {
354-
activityViewControntroller.popoverPresentationController.sourceView = self.webView;
362+
activityViewControntroller.popoverPresentationController.sourceView = self.pdfWebview;
355363
activityViewControntroller.popoverPresentationController.sourceRect = CGRectMake(self.pdfWebview.bounds.size.width/2, self.pdfWebview.bounds.size.height/4, 0, 0);
356364
}
357365

@@ -472,6 +480,7 @@ -(void)drawSignBox:(NSString*)titleText annotationKey:(NSString*)fieldName {
472480
PKInkingTool* tool = [[PKInkingTool alloc] initWithInkType:PKInkTypePen color:UIColor.blackColor width:10];
473481

474482
[self.canvas setTool:tool];
483+
[self.canvas setAllowsFingerDrawing:YES];
475484

476485
[self.signView addSubview:self.canvas];
477486
[self.signView bringSubviewToFront: self.canvas];

0 commit comments

Comments
 (0)