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

Commit e4e2385

Browse files
Merge pull request #3 from allanwolski/master
Change NSDocumentDirectory to NSCachesDirectory
2 parents c5eafba + 5b1485a commit e4e2385

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ios/Classes/FlutterPluginPdfViewerPlugin.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ -(NSString *)getNumberOfPages:(NSString *)url
3939
}
4040
CGPDFDocumentRef SourcePDFDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef)sourcePDFUrl);
4141
size_t numberOfPages = CGPDFDocumentGetNumberOfPages(SourcePDFDocument);
42-
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
43-
NSString *documentsDirectory = [paths objectAtIndex:0];
44-
NSString *filePathAndDirectory = [documentsDirectory stringByAppendingPathComponent:kDirectory];
42+
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
43+
NSString *temporaryDirectory = [paths objectAtIndex:0];
44+
NSString *filePathAndDirectory = [temporaryDirectory stringByAppendingPathComponent:kDirectory];
4545
NSError *error;
4646

4747
// Clear cache folder
@@ -76,9 +76,9 @@ -(NSString*)getPage:(NSString *)url ofPage:(size_t)pageNumber
7676
}
7777
CGPDFDocumentRef SourcePDFDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef)sourcePDFUrl);
7878
size_t numberOfPages = CGPDFDocumentGetNumberOfPages(SourcePDFDocument);
79-
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
80-
NSString *documentsDirectory = [paths objectAtIndex:0];
81-
NSString *filePathAndDirectory = [documentsDirectory stringByAppendingPathComponent:kDirectory];
79+
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
80+
NSString *temporaryDirectory = [paths objectAtIndex:0];
81+
NSString *filePathAndDirectory = [temporaryDirectory stringByAppendingPathComponent:kDirectory];
8282
NSError *error;
8383

8484
if (pageNumber > numberOfPages) {
@@ -96,7 +96,7 @@ -(NSString*)getPage:(NSString *)url ofPage:(size_t)pageNumber
9696
CGPDFPageRef SourcePDFPage = CGPDFDocumentGetPage(SourcePDFDocument, pageNumber);
9797
CGPDFPageRetain(SourcePDFPage);
9898
NSString *relativeOutputFilePath = [NSString stringWithFormat:@"%@/%@-%d.png", kDirectory, kFileName, (int)pageNumber];
99-
NSString *imageFilePath = [documentsDirectory stringByAppendingPathComponent:relativeOutputFilePath];
99+
NSString *imageFilePath = [temporaryDirectory stringByAppendingPathComponent:relativeOutputFilePath];
100100
CGRect sourceRect = CGPDFPageGetBoxRect(SourcePDFPage, kCGPDFMediaBox);
101101
UIGraphicsBeginPDFContextToFile(imageFilePath, sourceRect, nil);
102102
// Calculate resolution

0 commit comments

Comments
 (0)