Browse Source

PDFSamples(iOS)-代码注释优化和document形参重命名

yangliuhua 1 year ago
parent
commit
851f306f34

+ 20 - 15
Samples/Samples/Annotation/CAnnotaitonViewController.m

@@ -15,7 +15,7 @@
 
 //-----------------------------------------------------------------------------------------
 // The sample code illustrates how to create new annotation and delete anntation,
-// get anntation information  list using API.
+// get anntation information list using API.
 //-----------------------------------------------------------------------------------------
 
 @interface CAnnotaitonViewController ()
@@ -50,7 +50,7 @@
 #pragma mark - Samples Methods
 
 // Create all type annotation using API
-- (void)createTestAnnots:(CPDFDocument *)document {
+- (void)createTestAnnots:(CPDFDocument *)oldDocument {
     // Get Sandbox path for saving the PDFFile
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"Annoation"];
@@ -61,16 +61,17 @@
     
     // Save the document in the test PDF file
     self.anntationURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.anntationURL];
+    [oldDocument writeToURL:self.anntationURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.anntationURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.anntationURL];
     
+    //-----------------------------------------------------------------------------------------
     // Test of a free text annotation and ink annotation.
     CPDFPage *page1 = [document pageAtIndex:0];
 
     {
-        //  create a freetext annotation
+        //  Create a freetext annotation
         CPDFFreeTextAnnotation *freeText1 = [[CPDFFreeTextAnnotation alloc] initWithDocument:document];
         freeText1.contents = @"\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare."
         "\n\nAha!\n\nAnd there was much rejoicing!";
@@ -83,7 +84,7 @@
     }
     
     {
-        // create a ink annotation
+        // Create a ink annotation
         CPDFInkAnnotation *ink = [[CPDFInkAnnotation alloc] initWithDocument:document];
         CGPoint startPoint = CGPointMake(220, 505);
         CGPoint point1 = CGPointMake(100, 490);
@@ -98,7 +99,9 @@
         [page1 addAnnotation:ink];
     }
     
-    // set line with and Dotted line
+    //-----------------------------------------------------------------------------------------
+    // Test of line annotaiton
+    // Set line with and Dotted line
     CPDFBorder *border1 = [[CPDFBorder alloc] initWithStyle:CPDFBorderStyleDashed
                                                     lineWidth:1
                                                   dashPattern:@[@(2), @(1)]];
@@ -152,8 +155,9 @@
         [page2 addAnnotation:line3];
     }
     
-        // Create circle and square annotation
-        CPDFPage *page3 = [document pageAtIndex:2];
+    //-----------------------------------------------------------------------------------------
+    // Test of circle and square annotation
+    CPDFPage *page3 = [document pageAtIndex:2];
     {
         // Create a circle annotations.
         CPDFCircleAnnotation *circle1 = [[CPDFCircleAnnotation alloc] initWithDocument:document];
@@ -200,8 +204,8 @@
         [page3 addAnnotation:square2];
     }
     
-    
-    // Markup anntation
+    //-----------------------------------------------------------------------------------------
+    // Test of markup, note, link and sound anntation
     CPDFPage *page4 = [document pageAtIndex:3];
     {
         // Get array of search result
@@ -258,7 +262,8 @@
         }
     }
     
-    // Stamp annotation
+    //-----------------------------------------------------------------------------------------
+    // Test of stamp annotation
     CPDFPage *page5 = [document pageAtIndex:4];
     CGSize size5 = [document pageSizeAtIndex:4];
     CGFloat height5 = size5.height;
@@ -321,7 +326,7 @@
 }
 
 // Dele the first annotation
-- (void)deleteTestAnnot:(CPDFDocument *)document {
+- (void)deleteTestAnnot:(CPDFDocument *)oldDocument {
     // Get Sandbox path for saving the PDFFile
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"Annoation"];
@@ -332,10 +337,10 @@
     
     // Save the document in the PDF file
     self.deleteAnntationURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.deleteAnntationURL];
+    [oldDocument writeToURL:self.deleteAnntationURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.deleteAnntationURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.deleteAnntationURL];
     
     // Remove the fisrt annotation from document
     CPDFPage *page = [document pageAtIndex:0];

+ 9 - 9
Samples/Samples/Background/CBackgroundViewController.m

@@ -51,7 +51,7 @@
 
 #pragma mark - Samples Methods
 
-- (void)addColorBackground:(CPDFDocument *)document {
+- (void)addColorBackground:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1 : Set the document background color\n"];
     
@@ -65,10 +65,10 @@
     
     // Save the document in the test PDF file
     self.addColorBackgroundURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.addColorBackgroundURL];
+    [oldDocument writeToURL:self.addColorBackgroundURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.addColorBackgroundURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.addColorBackgroundURL];
     
     // Create color background
     CPDFBackground *background = document.background;
@@ -103,7 +103,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in AddColorBackgroundTest.pdf\n"];
 }
 
-- (void)addImageBackground:(CPDFDocument *)document {
+- (void)addImageBackground:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 2 : Set the document background image\n"];
     
@@ -117,10 +117,10 @@
     
     // Save the document in the test PDF file
     self.addImageBackgroundURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.addImageBackgroundURL];
+    [oldDocument writeToURL:self.addImageBackgroundURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.addImageBackgroundURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.addImageBackgroundURL];
     
     // Create image background
     CPDFBackground *background = document.background;
@@ -152,7 +152,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in AddImageBackgroundTest.pdf\n"];
 }
 
-- (void)deleteColorBackground:(CPDFDocument *)document {
+- (void)deleteColorBackground {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 3 :  Delete document background\n"];
     
@@ -171,7 +171,7 @@
    
     
     self.deleteBackgroundURL = [NSURL fileURLWithPath:writeFilePath];
-    document = [[CPDFDocument alloc] initWithURL:self.deleteBackgroundURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.deleteBackgroundURL];
     
     CPDFBackground *pageBackground = [document background];
     
@@ -290,7 +290,7 @@
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Running Watermark sample...\n\n"];
         [self addColorBackground:self.document];
         [self addImageBackground:self.document];
-        [self deleteColorBackground:self.document];
+        [self deleteColorBackground];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"\nDone!\n"];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
         

+ 9 - 9
Samples/Samples/Bates/CBatesViewController.m

@@ -50,7 +50,7 @@
 
 #pragma mark - Samples Methods
 
-- (void)addCommonBates:(CPDFDocument *)document {
+- (void)addCommonBates:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1: Insert common bates\n"];
     
@@ -64,10 +64,10 @@
     
     // Save the document in the test PDF file
     self.addCommonBatesURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.addCommonBatesURL];
+    [oldDocument writeToURL:self.addCommonBatesURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.addCommonBatesURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.addCommonBatesURL];
     
     // Create common bates
     CPDFBates *bates = document.bates;
@@ -103,7 +103,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in AddCommonBatesTest.pdf\n"];
 }
 
-- (void)editBates:(CPDFDocument *)document {
+- (void)editBates {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 2: Edit common bates\n"];
     
@@ -121,7 +121,7 @@
         [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:documentFolder] toURL:[NSURL fileURLWithPath:writeFilePath] error:nil];
     
     self.editBatesURL = [NSURL fileURLWithPath:writeFilePath];
-    document = [[CPDFDocument alloc] initWithURL:self.editBatesURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.editBatesURL];
     
     // Edit dates message
     CPDFBates *bates = document.bates;
@@ -156,7 +156,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in EditBatesTest.pdf\n"];
 }
 
-- (void)deleteBates:(CPDFDocument *)document {
+- (void)deleteBates {
 //     DeleteBatesTest
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 3: Delete common bates\n"];
@@ -175,7 +175,7 @@
         [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:documentFolder] toURL:[NSURL fileURLWithPath:writeFilePath] error:nil];
     
     self.deleteBatesURL = [NSURL fileURLWithPath:writeFilePath];
-    document = [[CPDFDocument alloc] initWithURL:self.deleteBatesURL];
+     CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.deleteBatesURL];
     
     CPDFBates *bates = document.bates;
     [bates clear];
@@ -284,8 +284,8 @@
         
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Running Bates sample...\n\n"];
         [self addCommonBates:self.document];
-        [self editBates:self.document];
-        [self deleteBates:self.document];
+        [self editBates];
+        [self deleteBates];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"\nDone!\n"];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
         

+ 5 - 5
Samples/Samples/Bookmark/CBookmarkViewController.m

@@ -48,7 +48,7 @@
 #pragma mark - Samples Methods
 
 // Create bookmark and go to page that had a bookmark
-- (void)createBookmark:(CPDFDocument *)document {
+- (void)createBookmark:(CPDFDocument *)oldDocument {
     // Get Sandbox path for saving the PDFFile
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"Bookmark"];
@@ -59,15 +59,14 @@
     
     // Save the document in the test PDF file
     self.bookmarkURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.bookmarkURL];
+    [oldDocument writeToURL:self.bookmarkURL];
     
-    // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.bookmarkURL];
+    // Open test pdf document
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.bookmarkURL];
     
     // Add bookmark
     [document addBookmark:@"my bookmark" forPageIndex:1];
     
-    // Go to page
     if ([document bookmarkForPageIndex:1]) {
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Go to page 2\n"];
     }
@@ -148,6 +147,7 @@
         
         // Refresh commandline message
         self.commandLineTextView.text = self.commandLineStr;
+        NSLog(@"%@", self.commandLineStr);
     } else {
         self.isRun = NO;
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"The document is null, can't open..\n\n"];

+ 26 - 23
Samples/Samples/Encrypt/CEncryptViewController.m

@@ -49,7 +49,7 @@
 
 #pragma mark - Samples Methods
 
-- (void)encryptByUserPassword:(CPDFDocument *)document {
+- (void)encryptByUserPassword:(CPDFDocument *)oldDocument {
     {
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1: Document use RC4 encrypt done\n"];
@@ -64,10 +64,10 @@
         
         // Save the document in the test PDF file
         NSURL *encryptUserRC4URL = [NSURL fileURLWithPath:writeFilePath];
-        [document writeToURL:encryptUserRC4URL];
+        [oldDocument writeToURL:encryptUserRC4URL];
         
         // Create a new document for test PDF file
-        document = [[CPDFDocument alloc] initWithURL:encryptUserRC4URL];
+        CPDFDocument *document = [[CPDFDocument alloc] initWithURL:encryptUserRC4URL];
         [self.userPasswordURLs addObject:encryptUserRC4URL];
         
         // Set encryption attributes
@@ -93,10 +93,10 @@
         
         // Save the document in the test PDF file
         NSURL *encryptUserAES128URL = [NSURL fileURLWithPath:writeFilePath];
-        [document writeToURL:encryptUserAES128URL];
+        [oldDocument writeToURL:encryptUserAES128URL];
         
         // Create a new document for test PDF file
-        document = [[CPDFDocument alloc] initWithURL:encryptUserAES128URL];
+        CPDFDocument *document = [[CPDFDocument alloc] initWithURL:encryptUserAES128URL];
         [self.userPasswordURLs addObject:encryptUserAES128URL];
         
         // Set encryption attributes
@@ -122,10 +122,10 @@
         
         // Save the document in the test PDF file
         NSURL *encryptUserAES256URL = [NSURL fileURLWithPath:writeFilePath];
-        [document writeToURL:encryptUserAES256URL];
+        [oldDocument writeToURL:encryptUserAES256URL];
         
         // Create a new document for test PDF file
-        document = [[CPDFDocument alloc] initWithURL:encryptUserAES256URL];
+        CPDFDocument *document = [[CPDFDocument alloc] initWithURL:encryptUserAES256URL];
         [self.userPasswordURLs addObject:encryptUserAES256URL];
         
         // Set encryption attributes
@@ -151,10 +151,10 @@
         
         // Save the document in the test PDF file
         NSURL *encryptUserNoEncryptAlgoURL = [NSURL fileURLWithPath:writeFilePath];
-        [document writeToURL:encryptUserNoEncryptAlgoURL];
+        [oldDocument writeToURL:encryptUserNoEncryptAlgoURL];
         
         // Create a new document for test PDF file
-        document = [[CPDFDocument alloc] initWithURL:encryptUserNoEncryptAlgoURL];
+        CPDFDocument *document = [[CPDFDocument alloc] initWithURL:encryptUserNoEncryptAlgoURL];
         [self.userPasswordURLs addObject:encryptUserNoEncryptAlgoURL];
         
         // Set encryption attributes
@@ -167,7 +167,7 @@
     }
 }
 
-- (void)encryptByOwnerPassword:(CPDFDocument *)document {
+- (void)encryptByOwnerPassword:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 5: Encrypt by owner password done\n"];
     
@@ -181,10 +181,10 @@
 
     // Save the document in the test PDF file
     NSURL *encryptOwnerRC4URL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:encryptOwnerRC4URL];
+    [oldDocument writeToURL:encryptOwnerRC4URL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:encryptOwnerRC4URL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:encryptOwnerRC4URL];
     [self.userPasswordURLs addObject:encryptOwnerRC4URL];
     
     // Set encryption attributes
@@ -199,7 +199,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in EncryptOwnerRC4Test.pdf\n\n"];
 }
 
-- (void)encryptByAllPasswords:(CPDFDocument *)document {
+- (void)encryptByAllPasswords:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 6: Encrypt by Both user and owner passwords done\n"];
     
@@ -213,10 +213,10 @@
     
     // Save the document in the test PDF file
     NSURL *encryptAllAES256URL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:encryptAllAES256URL];
+    [oldDocument writeToURL:encryptAllAES256URL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:encryptAllAES256URL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:encryptAllAES256URL];
     [self.userPasswordURLs addObject:encryptAllAES256URL];
     
     // Set encryption attributes
@@ -237,11 +237,11 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in EncryptAllAES256Test.pdf\n\n"];
 }
 
-- (void)unlock:(CPDFDocument *)document {
+- (void)unlock {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 7: Unlock with owner password and user password\n"];
     
-    // Save a document in Sandbox
+    // Get Sandbox path for saving the PDF File
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"Encrypt"];
     NSString *documentFolder = [[NSBundle mainBundle] pathForResource:@"AllPasswords" ofType:@"pdf"];
@@ -254,8 +254,10 @@
     if ([[NSFileManager defaultManager] fileExistsAtPath:documentFolder])
         [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:documentFolder] toURL:[NSURL fileURLWithPath:writeFilePath] error:nil];
     
+    // Unlock the document and print document permission information
+    // It is worth noting that the document is only unlocked, not decrypted, and the password is still required for the next opening
     NSURL *unlockAllPasswordsURL = [NSURL fileURLWithPath:writeFilePath];
-    document = [[CPDFDocument alloc] initWithURL:unlockAllPasswordsURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:unlockAllPasswordsURL];
     
     [document unlockWithPassword:@"Owner"];
     
@@ -268,11 +270,11 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingFormat:@"AllowsFormFieldEntry:%@\n\n", document.allowsFormFieldEntry ? @"YES" :  @"NO"];
 }
 
-- (void)decrypt:(CPDFDocument *)document {
+- (void)decrypt {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 8: Decrypt with owner password and user password\n"];
     
-    // Save a document in Sandbox
+    // Get Sandbox path for saving the PDF File
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"Encrypt"];
     NSString *documentFolder = [[NSBundle mainBundle] pathForResource:@"AllPasswords" ofType:@"pdf"];
@@ -285,8 +287,9 @@
     if ([[NSFileManager defaultManager] fileExistsAtPath:documentFolder])
         [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:documentFolder] toURL:[NSURL fileURLWithPath:writeFilePath] error:nil];
     
+    // Decrypt document
     NSURL *decryptAllPasswordsURL = [NSURL fileURLWithPath:writeFilePath];
-    document = [[CPDFDocument alloc] initWithURL:decryptAllPasswordsURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:decryptAllPasswordsURL];
     [self.userPasswordURLs addObject:decryptAllPasswordsURL];
     
     [document unlockWithPassword:@"Owner"];
@@ -393,8 +396,8 @@
         [self encryptByUserPassword:self.document];
         [self encryptByOwnerPassword:self.document];
         [self encryptByAllPasswords:self.document];
-        [self unlock:self.document];
-        [self decrypt:self.document];
+        [self unlock];
+        [self decrypt];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"\nDone!\n"];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
         

+ 3 - 3
Samples/Samples/FlattenedCopy/CFlattenedCopyViewController.m

@@ -46,7 +46,7 @@
 
 #pragma mark - Samples Methods
 
-- (void)flattenedCopy:(CPDFDocument *)document {
+- (void)flattenedCopy:(CPDFDocument *)oldDocument {
     // Get Sandbox path for saving the PDF File
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"FlattenedCopy"];
@@ -57,10 +57,10 @@
     
     // Save the document in the test PDF file
     self.flattenedCopyURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.flattenedCopyURL];
+    [oldDocument writeToURL:self.flattenedCopyURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.flattenedCopyURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.flattenedCopyURL];
     
     // Save flatten copy of document
     [document writeFlattenToURL:self.flattenedCopyURL];

+ 12 - 12
Samples/Samples/HeaderFooter/CHeaderFooterViewController.m

@@ -53,7 +53,7 @@
 
 #pragma mark - Samples Methods
 
-- (void)addCommonHeaderFooter:(CPDFDocument *)document {
+- (void)addCommonHeaderFooter:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1: Insert common header footer\n"];
     
@@ -67,10 +67,10 @@
     
     // Save the document in the test PDF file
     self.addCommonHeaderFooterURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.addCommonHeaderFooterURL];
+    [oldDocument writeToURL:self.addCommonHeaderFooterURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.addCommonHeaderFooterURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.addCommonHeaderFooterURL];
     
     // Create text header footer
     CPDFHeaderFooter *headerFooter = document.headerFooter;
@@ -97,7 +97,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in AddCommonHeaderFooterTest.pdf\n"];
 }
 
-- (void)addPageHeaderFooter:(CPDFDocument *)document {
+- (void)addPageHeaderFooter:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 2: Insert page header footer\n"];
     
@@ -111,10 +111,10 @@
     
     // Save the document in the test PDF file
     self.addPageHeaderFooterURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.addPageHeaderFooterURL];
+    [oldDocument writeToURL:self.addPageHeaderFooterURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.addPageHeaderFooterURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.addPageHeaderFooterURL];
     
     // Create page header footer
     CPDFHeaderFooter *headerFooter = document.headerFooter;
@@ -141,7 +141,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in AddPageHeaderFooterTest.pdf\n"];
 }
 
-- (void)editHeaderFooter:(CPDFDocument *)document {
+- (void)editHeaderFooter {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 3: Edit header footer\n"];
     
@@ -160,7 +160,7 @@
     
     // Edit text header footer
     self.editHeaderFooterURL = [NSURL fileURLWithPath:writeFilePath];
-    document = [[CPDFDocument alloc] initWithURL:self.editHeaderFooterURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.editHeaderFooterURL];
     
     CPDFHeaderFooter *headerFooter = document.headerFooter;
     [headerFooter setText:@"ComPDFKit Samples" atIndex:0];
@@ -178,7 +178,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in EditHeaderFooterTest.pdf\n"];
 }
 
-- (void)deleteHeaderFooter:(CPDFDocument *)document {
+- (void)deleteHeaderFooter {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 4: Delete header footer\n"];
     
@@ -196,7 +196,7 @@
         [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:documentFolder] toURL:[NSURL fileURLWithPath:writeFilePath] error:nil];
     
     self.deleteHeaderFooterURL = [NSURL fileURLWithPath:writeFilePath];
-    document = [[CPDFDocument alloc] initWithURL:self.deleteHeaderFooterURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.deleteHeaderFooterURL];
     
     // Delete header footer
     CPDFHeaderFooter *headerFooter = document.headerFooter;
@@ -312,8 +312,8 @@
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Running HeaderFooter sample...\n\n"];
         [self addCommonHeaderFooter:self.document];
         [self addPageHeaderFooter:self.document];
-        [self editHeaderFooter:self.document];
-        [self deleteHeaderFooter:self.document];
+        [self editHeaderFooter];
+        [self deleteHeaderFooter];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"\nDone!\n"];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
         

+ 6 - 6
Samples/Samples/InteractiveForms/CInteractiveFormsViewController.m

@@ -52,7 +52,7 @@
 #pragma mark - Samples Methods
 
 // Create all type form
-- (void)createTestForms:(CPDFDocument *)document {
+- (void)createTestForms:(CPDFDocument *)oldDocument {
     // Get Sandbox path for saving the PDFFile
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"InteractiveForms"];
@@ -63,10 +63,10 @@
     
     // Save the document in the test PDF file
     self.interactiveFormsURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.interactiveFormsURL];
+    [oldDocument writeToURL:self.interactiveFormsURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.interactiveFormsURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.interactiveFormsURL];
     
     // Create form using API
     CPDFPage *page = [document pageAtIndex:0];
@@ -294,7 +294,7 @@
 }
 
 // Dele the first form
-- (void)deleteForm:(CPDFDocument *)document {
+- (void)deleteForm:(CPDFDocument *)oldDocument {
     // Get Sandbox path for saving the PDFFile
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"InteractiveForms"];
@@ -305,10 +305,10 @@
     
     // Save the document in the test PDF file
     self.deleteInteractiveFormsURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.deleteInteractiveFormsURL];
+    [oldDocument writeToURL:self.deleteInteractiveFormsURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.deleteInteractiveFormsURL];
+     CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.deleteInteractiveFormsURL];
     
     // Remove the first form from document
     CPDFPage *page = [document pageAtIndex:0];

+ 4 - 4
Samples/Samples/Outline/COutlineViewController.m

@@ -48,7 +48,7 @@
 #pragma mark - Samples Methods
 
 // Create outline
-- (void)createOutline:(CPDFDocument *)document {
+- (void)createOutline:(CPDFDocument *)oldDocument {
     // Get Sandbox path for saving the PDF File
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"Outline"];
@@ -59,10 +59,10 @@
     
     // Save the document in the test PDF file
     self.outlineURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.outlineURL];
+    [oldDocument writeToURL:self.outlineURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.outlineURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.outlineURL];
     
     // Create outline root
     [document setNewOutlineRoot];
@@ -70,7 +70,7 @@
     // Get root from PDF document
     CPDFOutline *outline = [document outlineRoot];
     
-    // To insert a new outline and set outline text
+    // Insert a new outline node and set the outline title
     CPDFOutline *outlinePage1 = [outline insertChildAtIndex:0];
     outlinePage1.label = @"1. page1";
     

+ 6 - 6
Samples/Samples/PDFA/CPDFAViewController.m

@@ -49,7 +49,7 @@
 
 #pragma mark - Samples Methods
 
-- (void)convertToPDFA1a:(CPDFDocument *)document {
+- (void)convertToPDFA1a:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1: Convert PDF to PDFA1a format\n"];
     
@@ -63,10 +63,10 @@
     
     // Save the document in the test PDF file
     self.convertToPDFA1aURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.convertToPDFA1aURL];
+    [oldDocument writeToURL:self.convertToPDFA1aURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.convertToPDFA1aURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.convertToPDFA1aURL];
     
     // Save as PDFA1a format
     [document writePDFAToURL:self.convertToPDFA1aURL withType:CPDFTypePDFA1a];
@@ -74,7 +74,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in ConvertToPDFA1aTest.pdf\n\n"];
 }
 
-- (void)convertToPDFA1b:(CPDFDocument *)document {
+- (void)convertToPDFA1b:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1: Convert PDF to PDFA1b format\n"];
     
@@ -88,10 +88,10 @@
     
     // Save the document in the test PDF file
     self.convertToPDFA1bURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.convertToPDFA1bURL];
+    [oldDocument writeToURL:self.convertToPDFA1bURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.convertToPDFA1bURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.convertToPDFA1bURL];
     
     // Save as PDFA1b format
     [document writePDFAToURL:self.convertToPDFA1bURL withType:CPDFTypePDFA1a];

+ 24 - 23
Samples/Samples/PDFPage/CPDFPageViewController.m

@@ -66,8 +66,8 @@
 
 #pragma mark - Samples Methods
 
-// insert blank page
-- (void)insertBlankPage:(CPDFDocument *)document {
+// Insert blank page
+- (void)insertBlankPage:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1: Insert a blank A4-sized page into the sample document\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Opening the Samples PDF File\n"];
@@ -82,10 +82,11 @@
     
     // Save the document in the test PDF file
     self.insertBlankPageURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.insertBlankPageURL];
+    [oldDocument writeToURL:self.insertBlankPageURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.insertBlankPageURL];
+     CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.insertBlankPageURL];
+    
     // insert blank page
     [document insertPage:CGSizeMake(595, 852) atIndex:1];
     
@@ -97,8 +98,8 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in InsertBlankPage.pdf\n"];
 }
 
-// insert PDF document
-- (void)insertPDFPPage:(CPDFDocument *)document {
+// Insert PDF document
+- (void)insertPDFPPage:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 2: Import pages from another document into the example document\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Opening the Samples PDF File\n"];
@@ -121,12 +122,12 @@
     
     // Save the document in the test PDF file
     self.insertPDFPageURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.insertPDFPageURL];
+    [oldDocument writeToURL:self.insertPDFPageURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.insertPDFPageURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.insertPDFPageURL];
     
-    // insert PDF document
+    // Insert PDF document
     [document importPages:indexSet fromDocument:insertDocument atIndex:1];
     
     // Save the create insert PDF document action in document
@@ -135,7 +136,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in InsertPDFPage.pdf\n"];
 }
 
-// split page
+// Split page
 - (void)splitPages:(CPDFDocument *)document {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 3: Split a PDF document into multiple pages\n"];
@@ -191,8 +192,8 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in MergePages.pdf\n"];
 }
 
-// delete page
-- (void)deletePages:(CPDFDocument *)document {
+// Delete page
+- (void)deletePages:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 5: Delete the specified page of the document\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Opening the Samples PDF File\n"];
@@ -207,10 +208,10 @@
     
     // Save the document in the test PDF file
     self.removePageURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.removePageURL];
+    [oldDocument writeToURL:self.removePageURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.removePageURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.removePageURL];
     
     // Delete even-numbered pages of a document
     NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
@@ -226,8 +227,8 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in RemovePages.pdf\n"];
 }
 
-// rotate page
-- (void)rotatePages:(CPDFDocument *)document {
+// Rotate page
+- (void)rotatePages:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 6: Rotate document pages\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Opening the Samples PDF File\n"];
@@ -242,10 +243,10 @@
     
     // Create a new document for test PDF file
     self.rotatePageURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.rotatePageURL];
+    [oldDocument writeToURL:self.rotatePageURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.rotatePageURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.rotatePageURL];
     
     // Rotate the first page 90 degrees
     CPDFPage *page = [document pageAtIndex:0];
@@ -257,8 +258,8 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in RotatePage.pdf\n"];
 }
 
-// replace document page
-- (void)repalcePages:(CPDFDocument *)document {
+// Replace document page
+- (void)repalcePages:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 7: Replace specified pages of example documentation with other documentation specified pages\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Opening the Samples PDF File\n"];
@@ -273,10 +274,10 @@
     
     // Save the document in the test PDF file
     self.replacePageURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.replacePageURL];
+    [oldDocument writeToURL:self.replacePageURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.replacePageURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.replacePageURL];
     
     // Get PDF document
     NSString *filePathTest = [[NSBundle mainBundle] pathForResource:@"text" ofType:@"pdf"];
@@ -294,7 +295,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in ReplacePages.pdf\n"];
 }
 
-// export document page
+// Export document page
 - (void)extractPages:(CPDFDocument *)document {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 8: Extract specific pages of a document\n"];

+ 3 - 3
Samples/Samples/Redact/CRedactViewController.m

@@ -52,7 +52,7 @@
 
 #pragma mark - Samples Methods
 
-- (void)addRadact:(CPDFDocument *)document {
+- (void)addRadact:(CPDFDocument *)oldDocument {
     // Get Sandbox path for saving the PDF File
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"Redact"];
@@ -63,10 +63,10 @@
     
     // Save the document in the test PDF file
     self.addRedactURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.addRedactURL];
+    [oldDocument writeToURL:self.addRedactURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.addRedactURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.addRedactURL];
     
     // Add redact
     CPDFPage *page = [document pageAtIndex:0];

+ 0 - 2
Samples/Samples/SamplesBase/CSamplesBaseViewController.m

@@ -32,11 +32,9 @@
     self = [super initWithNibName:NSStringFromClass([self.superclass class]) bundle:nil];
     
     self.document = document;
-
     return self;
 }
 
-
 #pragma mark - UIViewController Methods
 
 - (void)viewDidLoad {

+ 0 - 1
Samples/Samples/TextExtract/CTextExtractViewController.m

@@ -80,7 +80,6 @@
 
 - (IBAction)buttonItemClick_openFile:(id)sender {
     // Determine whether to export the document
-   
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Choose a file to open...", nil) message:@"" preferredStyle:UIAlertControllerStyleAlert];
     if (UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM()) {
         alertController.popoverPresentationController.sourceView = self.openfileButton;

+ 3 - 3
Samples/Samples/TextSearch/CTextSearchViewController.m

@@ -46,7 +46,7 @@
 
 #pragma mark - Samples Methods
 
-- (void)searchText:(CPDFDocument *)document {
+- (void)searchText:(CPDFDocument *)oldDocument {
     // Get Sandbox path for saving the PDFFile
     NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
     NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"TextSearch"];
@@ -57,10 +57,10 @@
     
     // Save the document in the test PDF file
     self.textSearchURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.textSearchURL];
+    [oldDocument writeToURL:self.textSearchURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.textSearchURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.textSearchURL];
     
     // Get array of search result
     NSArray *resultArray = [document findString:@"PDF" withOptions:CPDFSearchCaseInsensitive];

+ 12 - 12
Samples/Samples/Watermark/CWatermarkViewController.m

@@ -54,7 +54,7 @@
 
 #pragma mark - Samples Methods
 
-- (void)addTextWatermark:(CPDFDocument *)document {
+- (void)addTextWatermark:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1: Insert text watermark\n"];
     
@@ -68,10 +68,10 @@
     
     // Save the document in the test PDF file
     self.addTextWatermarkURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.addTextWatermarkURL];
+    [oldDocument writeToURL:self.addTextWatermarkURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.addTextWatermarkURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.addTextWatermarkURL];
     
     // Create text watermark
     CPDFWatermark *watermark = [[CPDFWatermark alloc] initWithDocument:document type:CPDFWatermarkTypeText];
@@ -112,7 +112,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in AddTextWatermarkTest.pdf\n"];
 }
 
-- (void)addImageWatermark:(CPDFDocument *)document {
+- (void)addImageWatermark:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 2: Insert Image Watermark\n"];
     
@@ -126,10 +126,10 @@
     
     // Save the document in the test PDF file
     self.addImageWatermarkURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.addImageWatermarkURL];
+    [oldDocument writeToURL:self.addImageWatermarkURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.addImageWatermarkURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.addImageWatermarkURL];
     
     // Create a image watermark
     CPDFWatermark *watermark = [[CPDFWatermark alloc] initWithDocument:document type:CPDFWatermarkTypeImage];
@@ -161,7 +161,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in AddImageWatermarkTest.pdf\n"];
 }
 
-- (void)addTilesWatermark:(CPDFDocument *)document {
+- (void)addTilesWatermark:(CPDFDocument *)oldDocument {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 3: Insert Text Tiles Watermark\n"];
     
@@ -175,10 +175,10 @@
     
     // Save the document in the test PDF file
     self.addTilesWatermarkURL = [NSURL fileURLWithPath:writeFilePath];
-    [document writeToURL:self.addTilesWatermarkURL];
+    [oldDocument writeToURL:self.addTilesWatermarkURL];
     
     // Create a new document for test PDF file
-    document = [[CPDFDocument alloc] initWithURL:self.addTilesWatermarkURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.addTilesWatermarkURL];
     
     // Create text tiles watermark
     CPDFWatermark *watermark = [[CPDFWatermark alloc] initWithDocument:document type:CPDFWatermarkTypeText];
@@ -220,7 +220,7 @@
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in AddTilesWatermarkTest.pdf\n"];
 }
 
-- (void)deletetWatermark:(CPDFDocument *)document {
+- (void)deletetWatermark {
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
     self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 4:Delete Watermark\n"];
     
@@ -237,7 +237,7 @@
     if ([[NSFileManager defaultManager] fileExistsAtPath:documentFolder])
         [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:documentFolder] toURL:[NSURL fileURLWithPath:writeFilePath] error:nil];
     self.deleteWatermarkURL = [NSURL fileURLWithPath:writeFilePath];
-    document = [[CPDFDocument alloc] initWithURL:self.deleteWatermarkURL];
+    CPDFDocument *document = [[CPDFDocument alloc] initWithURL:self.deleteWatermarkURL];
     
     NSArray *waterArray = [document watermarks];
     [document removeWatermark:waterArray[0]];
@@ -361,7 +361,7 @@
         [self addTextWatermark:self.document];
         [self addImageWatermark:self.document];
         [self addTilesWatermark:self.document];
-        [self deletetWatermark:self.document];
+        [self deletetWatermark];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"\nDone!\n"];
         self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];