PDFTron is now Apryse. Same great products, new name.

New and Powerful Configuration APIs with PDFTron 6.8.7 for iOS

By David Luco | 2018 Sep 18

Sanity Image

We are pleased to introduce version 6.8.7 of PDFTron for iOS. This release adds new configuration APIs to disable annotation tools and other functionality, iOS 12 support, and more.

Disabling annotation tools and other functionality

With this release, it is now possible to control whether certain annotation can be created or edited without editing the open source Tools code.

For example, to disable creation and editing of text highlight annotations, simply call one of the new ToolManager methods:

//@data {"languages":["swift","objectivec"]}//
// Disable text highlight annotation creation and editing.
self.toolManager.setPermissionsFor(.highlight, canCreate: false, canEdit: false)
//@data {"languages":["swift","objectivec"]}//
// Disable text highlight annotation creation and editing.
[self.toolManager setPermissionsForExtendedAnnotType:PTExtendedAnnotTypeHighlight canCreate:NO canEdit:NO];

Other functionality provided by the Tools project, like text selection and form filling, can now also be controlled.

To disable all text selection, the ToolManager's new flexible "interaction tool" API or convenience properties can be used:

//@data {"languages":["swift","objectivec"]}//
// Disable text selection.
self.toolManager.setPermissionFor(.textSelection, enabled: false)

// OR
self.toolManager.isTextSelectionEnabled = false
//@data {"languages":["swift","objectivec"]}//
// Disable text selection.
[self.toolManager setPermissionForInteractionToolType:PTInteractionToolTypeTextSelection enabled:NO];

// OR
self.toolManager.textSelectionEnabled = NO;

For more information on the new ToolManager APIs for disabling tools, please see our guide.

Configuration APIs

In addition to the new APIs described above, it is also possible to configure the ToolManager used by our drop-in document viewer and tabbed viewer components.

To configure a PTDocumentViewController's tool manager, a powerful builder API can be used to disable annotation tools and other functionality:

//@data {"languages":["swift","objectivec"]}//
documentViewer.toolManager.configure(with: ToolManagerConfiguration { builder in
    // Disable editing of ink annotations.
    builder.annotPermissions = [
        .ink : [
            .canCreate : true,
            .canEdit : false,
        ],
    ]
    
    // Disable text selection.
    builder.interactionToolPermissions = [
        .textSelection : [
            .enabled : false,
        ],
    ]
})
//@data {"languages":["swift","objectivec"]}//
[documentViewer.toolManager configureWithConfiguration:[ToolManagerConfiguration configurationWithBuilder:^(ToolManagerConfigurationBuilder * builder) {
    // Disable editing of ink annotations.
    builder.annotPermissions = @{
        PTExtendedAnnotNameInk : @{
            PTAnnotPermissionKeyCanCreate : @YES,
            PTAnnotPermissionKeyCanEdit : @NO,
        },
    };
    
    // Disable text selection.
    builder.interactionToolPermissions = @{
        PTInteractionToolNameTextSelection : @{
            PTInteractionToolPermissionKeyEnabled : @NO,
        },
    };
}]];

This builder API can also be used to configure all the tabs of a PTTabbedDocumentViewController instance with the new configureWithToolManagerConfiguration: method.

And more...

For a full list of changes, please see the changelog for PDFTron 6.8.7 for iOS.

We hope you like these changes and any feedback is greatly appreciated. Please don't hesitate to contact us if you have any questions or suggestions. We also have many exciting new features planned for the coming weeks and months, so stay tuned.

Sanity Image

David Luco

Share this post

email
linkedIn
twitter