Skip to content
DemoSampleAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Predefine Annotations ​

ComPDF SDK has default values for some annotation properties, such as colors and line widths for ink annotations.

This is all handled in CPDFKitConfig, which is a global singleton. You can access it with CPDFKitShareConfig.

The current set of defaults is configured on the first run and saved in NSUserDefaults.

swift
// Author.
CPDFKitConfig.sharedInstance().setAnnotationAuthor("")

// Color.
CPDFKitConfig.sharedInstance().setHighlightAnnotationColor(UIColor.yellow)
CPDFKitConfig.sharedInstance().setUnderlineAnnotationColor(UIColor.blue)
CPDFKitConfig.sharedInstance().setStrikeoutAnnotationColor(UIColor.red)
CPDFKitConfig.sharedInstance().setSquigglyAnnotationColor(UIColor.black)
CPDFKitConfig.sharedInstance().setShapeAnnotationColor(UIColor.red)
CPDFKitConfig.sharedInstance().setShapeAnnotationInteriorColor(UIColor.clear)
CPDFKitConfig.sharedInstance().setFreehandAnnotationColor(UIColor.red)

// Opacity.
CPDFKitConfig.sharedInstance().setMarkupAnnotationOpacity(0.5)
CPDFKitConfig.sharedInstance().setShapeAnnotationOpacity(1.0)
CPDFKitConfig.sharedInstance().setShapeAnnotationInteriorOpacity(0.0)
CPDFKitConfig.sharedInstance().setFreehandAnnotationOpacity(1.0)

// Border Width.
CPDFKitConfig.sharedInstance().setShapeAnnotationBorderWidth(1.0)
CPDFKitConfig.sharedInstance().setFreehandAnnotationBorderWidth(1.0)
objective-c
// Author.
CPDFKitShareConfig.annotationAuthor = @"";

// Color.
CPDFKitShareConfig.highlightAnnotationColor = [UIColor yellowColor];
CPDFKitShareConfig.underlineAnnotationColor = [UIColor blueColor];
CPDFKitShareConfig.strikeoutAnnotationColor = [UIColor redColor];
CPDFKitShareConfig.squigglyAnnotationColor = [UIColor blackColor];
CPDFKitShareConfig.shapeAnnotationColor = [UIColor redColor];
CPDFKitShareConfig.shapeAnnotationInteriorColor = nil;
CPDFKitShareConfig.freehandAnnotationColor = [UIColor redColor];

// Opacity.
CPDFKitShareConfig.markupAnnotationOpacity = 0.5;
CPDFKitShareConfig.shapeAnnotationOpacity = 1.0;
CPDFKitShareConfig.shapeAnnotationInteriorOpacity = 0.0;
CPDFKitShareConfig.freehandAnnotationOpacity = 1.0;

// Border Width.
CPDFKitShareConfig.shapeAnnotationBorderWidth = 1.0;
CPDFKitShareConfig.freehandAnnotationBorderWidth = 1.0;