Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UIImage+PDF/PDFView.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
+(CGRect) mediaRectForData:(NSData *)data atPage:(NSUInteger)page;
+(NSUInteger) pageCountForURL:(NSURL *)resourceURL;
+(NSURL *)resourceURLForName:(NSString *)resourceName;
+(NSURL *)resourceURLForName:(NSString *)resourceName formBundle:(NSBundle *)bundle;
+(void)renderIntoContext:(CGContextRef)ctx url:(NSURL *)resourceURL data:(NSData *)resourceData size:(CGSize)size page:(NSUInteger)page preserveAspectRatio:(BOOL)preserveAspectRatio;

@end
13 changes: 13 additions & 0 deletions UIImage+PDF/PDFView.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ +(NSURL *)resourceURLForName:(NSString *)resourceName
}
}

+(NSURL *)resourceURLForName:(NSString *)resourceName formBundle:(NSBundle *)bundle
{
NSString *path = [bundle pathForResource:resourceName ofType:nil ];
if( path == nil )
{
return nil;
}
else
{
return ( resourceName ) ? [ NSURL fileURLWithPath:path] : nil;
}
}


+(void)renderIntoContext:(CGContextRef)ctx url:(NSURL *)resourceURL data:(NSData *)resourceData size:(CGSize)size page:(NSUInteger)page preserveAspectRatio:(BOOL)preserveAspectRatio
{
Expand Down
4 changes: 4 additions & 0 deletions UIImage+PDF/UIImage+PDF.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
+(void)setShouldCacheOnDisk:(BOOL)shouldCache; // Default = YES
+(void)setShouldCacheInMemory:(BOOL)shouldCache; // Default = NO

+(void)cleanDiskCache;
+(void)cleanMemoryCache;

+(UIImage *) imageOrPDFNamed:(NSString *)resourceName;
+(UIImage *) imageOrPDFWithContentsOfFile:(NSString *)path;

Expand All @@ -32,6 +35,7 @@

+(UIImage *) imageWithPDFNamed:(NSString *)resourceName fitSize:(CGSize)size atPage:(NSUInteger)page;
+(UIImage *) imageWithPDFNamed:(NSString *)resourceName fitSize:(CGSize)size;
+(UIImage *) imageWithPDFNamed:(NSString *)resourceName formBundle:(NSBundle *)bundle fitSize:(CGSize)size

+(UIImage *) originalSizeImageWithPDFNamed:(NSString *)resourceName atPage:(NSUInteger)page;
+(UIImage *) originalSizeImageWithPDFNamed:(NSString *)resourceName;
Expand Down
14 changes: 14 additions & 0 deletions UIImage+PDF/UIImage+PDF.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ +(NSString *)cacheFilenameForURL:(NSURL *)resourceURL atSize:(CGSize)size atScal
return cacheFilename;
}

+(void)cleanDiskCache {
NSString *cachesDirectory = [ NSSearchPathForDirectoriesInDomains( NSCachesDirectory, NSUserDomainMask, YES ) objectAtIndex:0 ];
NSString *cacheDirectory = [ NSString stringWithFormat:@"%@/__PDF_CACHE__", cachesDirectory ];
[[NSFileManager defaultManager] removeItemAtPath:cacheDirectory error:NULL];
}

+(void)cleanMemoryCache {
[_imagesCache removeAllObjects];
}

#pragma mark - Resource name

Expand Down Expand Up @@ -161,6 +170,11 @@ +(UIImage *) imageWithPDFNamed:(NSString *)resourceName fitSize:(CGSize)size
return [ self imageWithPDFURL:[ PDFView resourceURLForName:resourceName] fitSize:size ];
}

+(UIImage *) imageWithPDFNamed:(NSString *)resourceName formBundle:(NSBundle *)bundle fitSize:(CGSize)size
{
return [ self imageWithPDFURL:[ PDFView resourceURLForName:resourceName formBundle:bundle] fitSize:size ];
}

+(UIImage *) originalSizeImageWithPDFNamed:(NSString *)resourceName atPage:(NSUInteger)page
{
return [ self originalSizeImageWithPDFURL:[ PDFView resourceURLForName:resourceName ] atPage:page ];
Expand Down