This PlugPDF SDK iOS Developer Guide is temporarily unavailable while we are updating contents.

Please check back shortly!

PlugPDF SDK iOS Developer Guide

How to get annotations information?

In the PlugPDF, you can get annotations information programmatically.

In our pdf viewer, there are many types of annotations.

You may want to see annotations list and type and how many annotations are existing in a PDF.

Here is the way to collect all of the annotations.

NSArray *annots = [self.vc annots:self.vc.pageIdx];

You can save, remove and modify specific annotation with the annotations.

How to catch an annotation is added or removed?

In the PlugPDFDocumentViewEventDelegate, there is some delegate method for detecting annotation edit.

The below delegate method is called when an annotation is added.

#pragma mark - PlugPDFDocumentViewEventDelegate
- (void)AnnotisAdded:(UIControl *)annot


Also, you can detect when an annotation is removed.

- (void)AnnotisRemoved:(UIControl *)annot


In advance, you can detect which annotation is added or removed.

NSArray *annots = [self.vc annots:self.vc.pageIdx];

Save and remove Annotations

Following the code snippet, you can get annotations array and you can save the specific annotation with save method in the PlugPDF.

NSArray *annots = [self.vc annots:self.vc.pageIdx];
[self.vc saveAnnot: annots[]];

If you want to remove the first annotation at the first page, you can also remove the annotation with the below code.

NSArray *annots = [self.vc annots:self.vc.pageIdx];
[self.vc removeAnnot: annots[0]];

In advance, you can save or remove specific annotation by type.

The below code shows you that all of the ink annotations will remove in the PDF page.

NSArray *annots = [self.vc annots:self.vc.pageIdx];
 for (BaseAnnot *annot in annots ) {
     if ([annot isKindOfClass: InkAnnot.class]) [self.vc removeAnnot: annot];

On the other hand, the easiest way to remove all annotations in the specific pdf page.

You can use the below method.

- (void)removePageAnnot;

Flatten Annotations

How to flatten PDF annotations?

To protect the integrity of PDF files, people often want to flatten their PDF file.

The PlugPDF SDK provides the simplest way to make flatten PDF annotations in the PlugPDF SDK.

[self.vc flattenAnnotations];

You can also make a button and add the function in your pdf viewer.

Circle Annotation

PlugPDF SDK provides you circle annotation features, but you need to add some codes on your PDF Viewer.

First,  you need to add a button for the Circle annotation.

UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemSave
                                                                      target: self
                                                                      action: @selector(barButtonItem:)];
[viewController addLeftBarButtonItem: item];

Then, you need to add the below code to set the circle annotation tool.

- (void)barButtonItem: (id)sender
 [self.vc setTool:PlugPDFCircleTool];
 [self.vc setCircleAnnotColor: [UIColor blueColor]];
 [self.vc setCircleAnnotwidth: 1];
 [self.vc setCircleAnnotOpacity:0.5];
 [self.vc setCircleAnnotBorderColor:[UIColor redColor]];

Square Annotation

  Use the same way for square annotation. Please check the circle annotation guide. 

UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemSave
                                                                    target: self
                                                                   action: @selector(barButtonItem:)];
[viewController addLeftBarButtonItem: item];
- (void)barButtonItem: (id)sender{
 [self.vc setTool:PlugPDFSquareTool];
 [self.vc setSquareAnnotColor:[UIColor blueColor]];
 [self.vc setSquareAnnotwidth:1];
 [self.vc setSquareAnnotOpacity:0.5];
 [self.vc setSquareAnnotBorderColor:[UIColor redColor]];

TextMarkup Annotations ( Highlight, Underline, Strike Out)

In the PlugPDF SDK, PDF viewer provides TextMarkup features, such as Highlight, Underline, and StrikeOut.

The TextMarkup features do not allow a user to choose the various color.

However, you can change the TextMarkup color with the below code.

[viewController setTextHighlightToolColor:[UIColor greenColor]];
[viewController setTextUnderlineToolColor:[UIColor blueColor]];
[viewController setTextStrikeoutToolColor:[UIColor colorWithRed:0.5 green:0.2 blue:0.1 alpha:0.8]];

You can add a color picker popup and a user can choose these annotations color.

Ink Annotation

In the Ink annotation specification, you can change the color and the line width.

[viewController setInkToolLineColor:[UIColor redColor]];
[viewController setInkToolLineWidth: 5];

Note Annotation

You may do not like the note annotation image or editing function.

So, the PlugPDF SDK provides some properties that you can set note annotation.

The below code makes you can set the note annotation’s image.

[viewController setNoteIcon: [[NSBundle mainBundle] pathForResource: @"" ofType: @"png"]];

The note annotation pop-up function can be set YES or NO.

[viewController setEnableAnnotNotePopup:NO];

Moreover, you can choose whether enable or disable the note annotation.

[viewController setEnableAnnotNote:NO];

Eraser tool

The PlugPDF SDK for iOS supports three types of eraser tools.

typedef NS_OPTIONS(NSUInteger, PlugPDFDocumentEraserType) {
 PlugPDFDocumentEraserTypeBasic                 = 0,    // Eraser tool with Drag,singletap and selected area event.
 PlugPDFDocumentEraserTypeSelectedArea          = 1,    // Eraser tool with selected area event.
 PlugPDFDocumentEraserTypeClickWithDrag         = 2    // Eraser tool with Drag and singletap event.

Simply, you just need 1 line code to set the eraser type.

[viewController setEraserType: PlugPDFDocumentEraserTypeBasic];