Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Pn 53 (#94)
Browse files Browse the repository at this point in the history
* I removed the line from 42 to 63 for deleting unused saved cache files.
It makes memory problem when you try to open the PDF after several times.

* remove .idea folder

Co-authored-by: Eko Prasetyo <[email protected]>
  • Loading branch information
lohanidamodar and illukinati authored Dec 31, 2021
1 parent 5159064 commit a8574a8
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions ios/Classes/FlutterPluginPdfViewerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,8 @@ -(NSString *)getNumberOfPages:(NSString *)url
}
CGPDFDocumentRef SourcePDFDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef)sourcePDFUrl);
size_t numberOfPages = CGPDFDocumentGetNumberOfPages(SourcePDFDocument);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *temporaryDirectory = [paths objectAtIndex:0];
NSString *filePathAndDirectory = [temporaryDirectory stringByAppendingPathComponent:kDirectory];
NSError *error;

// Clear cache folder
if ([[NSFileManager defaultManager] fileExistsAtPath:filePathAndDirectory]) {
NSLog(@"[FlutterPluginPDFViewer] Removing old documents cache");
[[NSFileManager defaultManager] removeItemAtPath:filePathAndDirectory error:&error];
}

if (![[NSFileManager defaultManager] createDirectoryAtPath:filePathAndDirectory
withIntermediateDirectories:YES
attributes:nil
error:&error])
{
NSLog(@"Create directory error: %@", error);
return nil;
}
// Generate random file size for this document

kFileName = [[NSUUID UUID] UUIDString];

NSLog(@"[FlutterPluginPdfViewer] File has %zd pages", numberOfPages);
NSLog(@"[FlutterPluginPdfViewer] File will be saved in cache as %@", kFileName);
return [NSString stringWithFormat:@"%zd", numberOfPages];
}

Expand Down

0 comments on commit a8574a8

Please sign in to comment.