Yet another PDF Kit is a independent PDF Kit written in objective-c for parsing and manipulating PDF's. YAPDFKit is completely independent of Apple's PDFKit
For specific cases YAPDFKit can be of great help, but it's currently in an Alpha state.
- Usable in OS X and iOS projects
- Oldest Mac target: Mac OS X 10.7
- Parser to create PDF Structure
- Extract Deflated and other filtered content
- Some essential Postscript knowledge and features
- Modify PDF Objects directly in PDF
Use these includes:
#import <Foundation/Foundation.h>
#import "YPDocument.h"
In this example we add a purple rectangle below the text of every page. See main.c for a working version of this example.
NSString *file =@"/tmp/2-page-pages-export.pdf";
NSData *fileData = [NSData dataWithContentsOfFile:file];
YPDocument *document = [[YPDocument alloc] initWithData:fileData];
YPPages *pg = [[YPPages alloc] initWithDocument:document];
NSLog(@"page count: %d", [pg getPageCount]);
//All Pages unsorted
NSArray * allPages = [document getAllObjectsWithKey:@"Type" value:@"Page"];
for (YPObject* page in allPages) {
NSString *docContentNumber = [[document getInfoForKey:@"Contents" inObject:[page getObjectNumber]] getReferenceNumber];
YPObject * pageContentsObject = [document getObjectByNumber:docContentNumber];
NSData *plainContent = [pageContentsObject getUncompressedStreamContentsAsData];
NSData *data2 = [@"q /Cs1 cs 0.4 0 0.6 sc 250 600 100 100 re f q " dataUsingEncoding:NSASCIIStringEncoding];
NSRange firstPartRange = {0,64};
NSRange lastPartRange = {64, ([plainContent length]-64)};
NSData *data1 = [plainContent subdataWithRange:firstPartRange];
NSData *data3 = [plainContent subdataWithRange:lastPartRange];
NSMutableData * newPlainContent = [data1 mutableCopy];
[newPlainContent appendData:data2];
[newPlainContent appendData:data3];
[pageContentsObject setStreamContentsWithData:newPlainContent];
[document addObjectToUpdateQueue:pageContentsObject];
}
[document updateDocumentData];
[[document modifiedPDFData] writeToFile:@"/tmp/2-page-pages-export-mod.pdf" atomically:YES];
- Return all document objects
- Deflate content object stream
- cleanup deflate function
- Enable Existing Tests
- Enable travis
- Add some file intergration tests
- Return all document pages
- Return page content object
- Add new object at file bottom
- Add new xref table at file bottom
- Add new trailer
- calculate file length
- calc object length
- fix and check all offsets;
- Make podspec
- Replace PDF prefix with YAPDF everywhere
- remove nsstring convertion for streams
- add included pdf in main.c
- cleanup file reader
- more examples
- Return all page objects / per page
- add inflate function
- Exact Text (ProcessOutput)
- Code Coverage
- Rename all object attributes classes with a name including object
This project started because we needed to remove white backgrounds from PDF's made by Applications like Apple Pages. YAPDFKit is used in the PDF Letterhead App.
- Fork it ( https://github.com/[my-github-username]/YAPDFKit/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- YAPDFKit is a fork of PDFCoolParser by @kozliappi.
- YAPDFKit is sponsored by Lingewoud and MunsterMade.