How do I Present a PSPDFTabbedViewController in Cordova?
Q: How do I Present a PSPDFTabbedViewController
in Cordova?
A: Our Cordova plugin was designed to present a PDFViewController
modally. If your use case requires you to present a PDFTabbedViewController
, you could extend the plugin in your own fork, as seen below.
1. Update pspdfkit.js
Declare presentTabs
in pspdfkit.js
, like this:
this.presentTabs = function(path, callback) { cordova.exec(function (result) { if (callback) callback(result); }, function (error) { if (callback) callback(error); }, 'PSPDFKitPlugin', 'presentTabs', [path]); }
2. Update PSPDFKitPlugin.m
Implement the newly declared API in Objective-C, like so:
- (void)presentTabs:(CDVInvokedUrlCommand *)command { NSArray *paths = [command argumentAtIndex:0]; PSPDFTabbedViewController *tabbedViewController = [[PSPDFTabbedViewController alloc] init]; NSMutableArray *documents = [NSMutableArray new]; for (NSString *path in paths) { PSPDFDocument *document = [[PSPDFDocument alloc] initWithURL:[self fileURLWithPath:path]]; if (document) { [documents addObject:document]; } } tabbedViewController.documents = [documents copy]; _navigationController = [[UINavigationController alloc] initWithRootViewController:tabbedViewController]; if (!_navigationController.presentingViewController) { [self.viewController presentViewController:_navigationController animated:YES completion:^{ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId]; }]; } else { [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR] callbackId:command.callbackId]; } }
3. Usage
This is how the newly added API would look in your Cordova Javascript code:
PSPDFKit.presentTabs(['pdf/PSPDFKit 8 QuickStart Guide.pdf', 'pdf/Form_example.pdf']);

For more details about please take a look at our How to Expose native iOS APIs to Cordova blog post.