In the past few years, we’ve always been focused on PDF Reader Pro and achieved impressive achievements. And more and more users want to integrate our SDK into their own apps. After in-depth thinking and thorough market research, now we are taking a meaningful step in this area.
Today, we are thrilled to introduce ComPDFKit, a battle-tested product that makes our technology available to anyone. Although this is our first edition, we have drawn on the experience of the market and the basic functions are relatively complete.
ComPDFKit consists of ComPDFKit PDF SDK and ComPDFKit Conversion SDK, and in this article, we present a list of features and related use cases of ComPDFKit PDF SDK.
Features
You can integrate ComPDFKit PDF SDK functionality on iOS, Android, and Windows platforms, and the corresponding programming languages are Objective-C (compatible with Swift), Java (compatible with Kotlin), and C#.
Here are a large set of features that ComPDFKit PDF SDK comes with:
・Standard page display modes, including scrolling, double page, crop mode, and cover mode.
・Navigation with thumbnails, outlines, and bookmarks.
・Create, edit and remove annotations, including notes, link, free text, line, square, circle, highlight, underline, squiggly, strikeout, ink, and stamp.
・Support for annotation appearances.
・Supported form fields: push button, check box, radio button, text field, combo box, list box, and signature.
・PDF manipulation, including split pages, extract pages, and merge pages.
・Page edit, including delete pages, insert pages, crop pages, move pages, rotate pages, replace pages, and exchange pages.
・Encrypt and decrypt PDFs, including permission setting and password protected.
Click here to learn more information about our features.
ComPDFKit has received rave reviews, and here’s the comment from Softlay.
Use Cases
Below are some key examples that are designed to give you an idea of how you can get started with ComPDFKit PDF SDK.
Creating Annotations
When reading a PDF document and seeing something important that is well-written or thought-provoking, you often want to make marks or write down your thoughts
aside.
ComPDFKit PDF SDK includes a wide variety of standard annotations, such as line, highlight, square, note, and so on. Each of them is added to the project in a similar way, editing and removing them are also supported. In addition, you can modify the color and shape of annotations to suit your needs.
C#
CPDFDocument document = CPDFDocument.InitWithFilePath("filePath");
CPDFPage page = document.PageAtIndex(0);
CPDFTextAnnotation text = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_TEXT) as CPDFTextAnnotation;
text.SetContent("test");
text.SetRect(new CRect(0,50,50,0));
byte[] color = {255,0,0};
text.SetColor(color);
text.UpdateAp();
JavaScript
NSURL *url = [NSURL fileURLWithPath:pdfPath];
CPDFDocument *document = [[[CPDFDocument alloc] initWithURL:url] autorelease];
CPDFPage *page = [document pageAtIndex:0];
CPDFTextAnnotation *text = [[[CPDFTextAnnotation alloc] initWithDocument:document] autorelease];
text.contents = @"test";
text.bounds = CGRectMake(0, 0, 50, 50);
text.color = [UIColor yellowColor];
[page addAnnotation:text];
Java
// open pdf document
CPDFReaderView readerView = findViewById(R.id.readerview);
CPDFDocument document = new CPDFDocument(context);
CPDFDocument.PDFDocumentError error = document.open("pdfPath");
if (error == CPDFDocument.PDFDocumentError.PDFDocumentErrorSuccess) {
//The document is opened successfully and data can be parsed and manipulated.
readerView.setPDFDocument(document);
if (document.getPageCount() > 0){
//insert page number
int pageNumber = 0;
//get page instance of pdf
CPDFPage page = document.pageAtIndex(pageNumber);
CPDFTextAnnotation textAnnotation = (CPDFTextAnnotation) page.addAnnot(CPDFAnnotation.Type.TEXT);
//get the actual size of the page you want to insert
RectF pageSize = readerView.getPageNoZoomSize(pageNumber);
RectF insertRect = new RectF(0,0,50,50);
//coordinate conversion
insertRect = document.pageAtIndex(pageNumber).convertRectToPage(readerView.isCropMode(),pageSize.width(),pageSize.height(),insertRect);
textAnnotation.setRect(insertRect);
textAnnotation.setContent("Hello world!");
textAnnotation.updateAp();
readerView.reloadPages();
}
} else {
//The PDF file failed to open. You can refer to the API file for specific error messages.
}
PDF Manipulation
If a PDF document contains dozens of pages while only several pages are useful to you, you’d like to save the specific pages as a new document.
With ComPDFKit PDF SDK, you can put any pages into a blank document, whether they are continuous or scattered. You can also choose to split a document by a certain number of pages or evenly into multiple documents.
C#
// CPDFDocument document = CPDFDocument.CreateDocument();
// CPDFDocument document1 = CPDFDocument.InitWithFilePath("filePath");
// Pages that need to be split, e.g. 2 to 5 pages
document.ImportPagesAtIndex(document1,"2-5",0);
// Save path
document.WriteToFilePath("savePath");
JavaScript
// CPDFDocument *document = [[[CPDFDocument alloc] init] autorelease];
// File path
NSString *path1 = @"...";
NSURL *url1 = [NSURL fileURLWithPath:path1];
CPDFDocument *document1 = [[[CPDFDocument alloc] initWithURL:url1] autorelease];
// Pages that need to be split, e.g. 2 to 5 pages
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, 4)];
[document importPages:indexSet fromDocument:document1 atIndex:0];
// Save path
NSString *path = @"...";
NSURL *url = [NSURL fileURLWithPath:path];
[document writeToURL:url];
Java
// CPDFDocument newDocument = CPDFDocument.createDocument(context);
// Open document from file path
CPDFDocument document = new CPDFDocument(context);
document.open(pdfPath);
// Pages that need to be split, e.g. 2 to 5 pages, start insert index is 0
newDocument.importPages(document, pageNums, 1, 4, 0);
// Save path, don't remove password of pdf file
newDocument.saveAs(filePath, false);
PDF Permission
Sometimes you distribute a PDF document to others, hoping they can only read and copy the document without any other permissions. With ComPDFKit PDF SDK, you can solve this problem effortlessly.
A PDF document can set two different passwords, a permissions or owner password and an open or user password. When an owner password is set, you can configure a set of permissions. For example, you can lock printing permissions with the owner password to make sure that someone who only knows the user password can use other functions except printing.
C#
CPDFDocument document = CPDFDocument.InitWithFilePath("filePath");
CPDFPermissionsInfo permission = new CPDFPermissionsInfo();
document.Encrypt("UserPassword", "ownerPassword", permission);
document.WriteToFilePath("savePath");
JavaScript
NSURL *url = [NSURL fileURLWithPath:@""];
CPDFDocument *document = [[[CPDFDocument alloc] initWithURL:url] autorelease];
NSURL *surl = [NSURL fileURLWithPath:@""];
NSDictionary *options = @{CPDFDocumentOwnerPasswordOption : @"The owner password",
CPDFDocumentUserPasswordOption : @"The user password",
CPDFDocumentAllowsPrintingOption : @(YES),
CPDFDocumentAllowsHighQualityPrintingOption : @(NO),
CPDFDocumentAllowsCopyingOption : @(NO),
CPDFDocumentAllowsDocumentChangesOption : @(NO),
CPDFDocumentAllowsDocumentAssemblyOption : @(NO),
CPDFDocumentAllowsCommentingOption : @(NO),
CPDFDocumentAllowsFormFieldEntryOption : @(NO)};
[document writeToURL:surl withOptions:options];
Java
// Open document from file path
CPDFDocument document = new CPDFDocument(context);
document.open(pdfPath);
//set user password
document.setUserPassword(password);
//set owner password
document.setOwnerPassword(password);
//save document
document.save();
The PDF specification defines the permissions, including printing, copying, document changes, commenting, etc.
Conclusion
It is a new chapter for ComPDFKit PDF SDK, and we will continue expanding the range of features to improve our product in future iterations. Please stay tuned for our blogs and changelogs for future releases.
If you have any feedback, or suggestions on how we can satisfy your needs better, please get in touch with us.