Jelajahi Sumber

PDFSamples(iOS)-flattenedCopy samples 的完成

yangliuhua 1 tahun lalu
induk
melakukan
bd65c69f8f

+ 28 - 0
Samples/Samples.xcodeproj/project.pbxproj

@@ -35,6 +35,8 @@
 		C97699A42A5BAF8D00187038 /* CRedactViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C97699A32A5BAF8D00187038 /* CRedactViewController.m */; };
 		C97699A82A5BD1B400187038 /* CEncryptViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C97699A72A5BD1B400187038 /* CEncryptViewController.m */; };
 		C97699AC2A5BEB9B00187038 /* AllPasswords.pdf in Resources */ = {isa = PBXBuildFile; fileRef = C97699AB2A5BEB9B00187038 /* AllPasswords.pdf */; };
+		C97699B02A5BF4A700187038 /* CPDFAViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C97699AF2A5BF4A700187038 /* CPDFAViewController.m */; };
+		C97699B42A5BFA4A00187038 /* CFlattenedCopyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C97699B32A5BFA4A00187038 /* CFlattenedCopyViewController.m */; };
 		C9E361142A5273BC004D31BE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E361132A5273BC004D31BE /* AppDelegate.m */; };
 		C9E361172A5273BC004D31BE /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E361162A5273BC004D31BE /* SceneDelegate.m */; };
 		C9E3611A2A5273BC004D31BE /* CSamplesFuctionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E361192A5273BC004D31BE /* CSamplesFuctionViewController.m */; };
@@ -110,6 +112,10 @@
 		C97699A62A5BD1B400187038 /* CEncryptViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CEncryptViewController.h; sourceTree = "<group>"; };
 		C97699A72A5BD1B400187038 /* CEncryptViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CEncryptViewController.m; sourceTree = "<group>"; };
 		C97699AB2A5BEB9B00187038 /* AllPasswords.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = AllPasswords.pdf; sourceTree = "<group>"; };
+		C97699AE2A5BF4A700187038 /* CPDFAViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFAViewController.h; sourceTree = "<group>"; };
+		C97699AF2A5BF4A700187038 /* CPDFAViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFAViewController.m; sourceTree = "<group>"; };
+		C97699B22A5BFA4A00187038 /* CFlattenedCopyViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFlattenedCopyViewController.h; sourceTree = "<group>"; };
+		C97699B32A5BFA4A00187038 /* CFlattenedCopyViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CFlattenedCopyViewController.m; sourceTree = "<group>"; };
 		C995A2E42A53FEAD00762127 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		C9E3610F2A5273BC004D31BE /* Samples.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Samples.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		C9E361122A5273BC004D31BE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -322,6 +328,24 @@
 			path = Encrypt;
 			sourceTree = "<group>";
 		};
+		C97699AD2A5BF44600187038 /* PDFA */ = {
+			isa = PBXGroup;
+			children = (
+				C97699AE2A5BF4A700187038 /* CPDFAViewController.h */,
+				C97699AF2A5BF4A700187038 /* CPDFAViewController.m */,
+			);
+			path = PDFA;
+			sourceTree = "<group>";
+		};
+		C97699B12A5BFA2800187038 /* FlattenedCopy */ = {
+			isa = PBXGroup;
+			children = (
+				C97699B22A5BFA4A00187038 /* CFlattenedCopyViewController.h */,
+				C97699B32A5BFA4A00187038 /* CFlattenedCopyViewController.m */,
+			);
+			path = FlattenedCopy;
+			sourceTree = "<group>";
+		};
 		C9E361062A5273BC004D31BE = {
 			isa = PBXGroup;
 			children = (
@@ -369,6 +393,8 @@
 				C976999D2A5BA19600187038 /* Bates */,
 				C97699A12A5BAF4F00187038 /* Redact */,
 				C97699A52A5BD19A00187038 /* Encrypt */,
+				C97699AD2A5BF44600187038 /* PDFA */,
+				C97699B12A5BFA2800187038 /* FlattenedCopy */,
 				C9E3611B2A5273BC004D31BE /* Main.storyboard */,
 				C9E3611E2A5273BF004D31BE /* Assets.xcassets */,
 				C995A2E42A53FEAD00762127 /* Info.plist */,
@@ -493,6 +519,7 @@
 				C976999C2A5ACAAB00187038 /* CHeaderFooterViewController.m in Sources */,
 				C97699982A5AAEF900187038 /* CBackgroundViewController.m in Sources */,
 				C9E361252A5273BF004D31BE /* main.m in Sources */,
+				C97699B42A5BFA4A00187038 /* CFlattenedCopyViewController.m in Sources */,
 				C97699892A5800A100187038 /* CTextExtractViewController.m in Sources */,
 				C97699A42A5BAF8D00187038 /* CRedactViewController.m in Sources */,
 				C97699652A554F4800187038 /* CPDFToImageViewController.m in Sources */,
@@ -500,6 +527,7 @@
 				C97699542A55162B00187038 /* COutlineViewController.m in Sources */,
 				C97699712A5595DF00187038 /* CAnnotaitonViewController.m in Sources */,
 				C97699692A556AE400187038 /* CTextSearchViewController.m in Sources */,
+				C97699B02A5BF4A700187038 /* CPDFAViewController.m in Sources */,
 				C9E361172A5273BC004D31BE /* SceneDelegate.m in Sources */,
 				C9E3613A2A53AD60004D31BE /* CSamplesBaseViewController.m in Sources */,
 			);

+ 1 - 0
Samples/Samples/CSamplesFuctionViewController.h

@@ -30,6 +30,7 @@ typedef NS_ENUM(NSInteger, CSamplesType)  {
     CSamplesTypePDFBates,
     CSamplesTypePDFRedact,
     CSamplesTypeEncry,
+    CSamplesTypePDFA,
     CSamplesTypeFlattenedCopy
 };
 

+ 17 - 0
Samples/Samples/CSamplesFuctionViewController.m

@@ -29,6 +29,8 @@
 #import "CBatesViewController.h"
 #import "CRedactViewController.h"
 #import "CEncryptViewController.h"
+#import "CPDFAViewController.h"
+#import "CFlattenedCopyViewController.h"
 
 #import <ComPDFKit/ComPDFKit.h>
 
@@ -237,6 +239,21 @@
             [self.navigationController pushViewController:encryptVC animated:YES];
         }
             break;
+        case CSamplesTypePDFA:
+        {
+            CPDFAViewController *PDFAVC = [[CPDFAViewController alloc] initWithDocument:self.document];
+            [self.navigationController pushViewController:PDFAVC animated:YES];
+        }
+            break;
+        case CSamplesTypeFlattenedCopy:
+        {
+            NSString *filePath = self.filePaths[3];
+            NSURL *url = [NSURL fileURLWithPath:filePath];
+            CPDFDocument *document = [[CPDFDocument alloc] initWithURL:url];
+            CFlattenedCopyViewController *flattenedCopyVC = [[CFlattenedCopyViewController alloc] initWithDocument:document];
+            [self.navigationController pushViewController:flattenedCopyVC animated:YES];
+        }
+            break;
             
         default:
             break;

+ 21 - 0
Samples/Samples/FlattenedCopy/CFlattenedCopyViewController.h

@@ -0,0 +1,21 @@
+//
+//  CFlattenedCopyViewController.h
+//  Samples
+//
+//  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+//
+//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+//  This notice may not be removed from this file.
+//
+
+#import "CSamplesBaseViewController.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CFlattenedCopyViewController : CSamplesBaseViewController
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 139 - 0
Samples/Samples/FlattenedCopy/CFlattenedCopyViewController.m

@@ -0,0 +1,139 @@
+//
+//  CFlattenedCopyViewController.m
+//  Samples
+//
+//  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+//
+//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+//  This notice may not be removed from this file.
+//
+
+#import "CFlattenedCopyViewController.h"
+
+#import <ComPDFKit/ComPDFKit.h>
+
+//-----------------------------------------------------------------------------------------
+// The sample code illustrates how do I create a copy of Flattened using API.
+//-----------------------------------------------------------------------------------------
+
+@interface CFlattenedCopyViewController ()
+
+@property (nonatomic, strong) CPDFDocument *document;
+
+@property (nonatomic, assign) BOOL isRun;
+
+@property (nonatomic, strong) NSString *commandLineStr;
+
+@property (nonatomic, strong) NSURL *flattenedCopyURL;
+
+@end
+
+@implementation CFlattenedCopyViewController
+
+#pragma mark - UIViewController Methods
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    self.explainLabel.text = NSLocalizedString(@"The sample code illustrates how do I create a copy of Flattened using API.", nil);
+    
+    self.commandLineTextView.text = @"";
+    self.isRun = NO;
+    self.commandLineStr = @"";
+}
+
+#pragma mark - Samples Methods
+
+- (void)flattenedCopy:(CPDFDocument *)document {
+    // Save a document in Sandbox
+    NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
+    NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"FlattenedCopy"];
+    
+    // Copy file
+    if (![[NSFileManager defaultManager] fileExistsAtPath:writeDirectoryPath])
+        [[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:writeDirectoryPath] withIntermediateDirectories:YES attributes:nil error:nil];
+    NSString *writeFilePath = [NSString stringWithFormat:@"%@/%@.pdf",writeDirectoryPath,@"FlattenedCopyTest"];
+    
+    self.flattenedCopyURL = [NSURL fileURLWithPath:writeFilePath];
+    [document writeToURL:self.flattenedCopyURL];
+    document = [[CPDFDocument alloc] initWithURL:self.flattenedCopyURL];
+    
+    [document writeFlattenToURL:self.flattenedCopyURL];
+
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in FlattenedCopyTest.pdf\n"];
+}
+
+- (void)openFile {
+    UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:@[self.flattenedCopyURL] applicationActivities:nil];
+        activityVC.definesPresentationContext = YES;
+    if (UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM()) {
+        activityVC.popoverPresentationController.sourceView = self.openfileButton;
+        activityVC.popoverPresentationController.sourceRect = self.openfileButton.bounds;
+    }
+    [self presentViewController:activityVC animated:YES completion:nil];
+    activityVC.completionWithItemsHandler = ^(UIActivityType  _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {
+
+        if (completed) {
+            NSLog(@"Success!");
+        } else {
+            NSLog(@"Failed Or Canceled!");
+        }
+    };
+}
+
+#pragma mark - Action
+
+- (IBAction)buttonItemClick_openFile:(id)sender {
+    // Determine whether to export the document
+    if (self.isRun) {
+        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;
+            alertController.popoverPresentationController.sourceRect = self.openfileButton.bounds;
+        }
+        
+        UIAlertAction *textSearchAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"   FlattenedCopyTest.pdf   ", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            // Open CreateBookmarkTest.pdf
+            [self openFile];
+        }];
+        
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil];
+        
+        [alertController addAction:textSearchAction];
+        [alertController addAction:cancelAction];
+        
+        [self presentViewController:alertController animated:NO completion:nil];
+    } else {
+        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;
+            alertController.popoverPresentationController.sourceRect = self.openfileButton.bounds;
+        }
+        
+        UIAlertAction *noAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"No files for this sample.", nil) style:UIAlertActionStyleDefault handler:nil];
+        
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil];
+        
+        [alertController addAction:noAction];
+        [alertController addAction:cancelAction];
+        
+        [self presentViewController:alertController animated:NO completion:nil];
+    }
+}
+
+- (IBAction)buttonItemClick_run:(id)sender {
+    self.isRun = YES;
+    
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Running FlattenedCopy sample...\n\n"];
+    [self flattenedCopy:self.document];
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"\nDone!\n"];
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
+    
+    // Refresh commandline message
+    self.commandLineTextView.text = self.commandLineStr;
+}
+
+
+@end

+ 21 - 0
Samples/Samples/PDFA/CPDFAViewController.h

@@ -0,0 +1,21 @@
+//
+//  CPDFAViewController.h
+//  Samples
+//
+//  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+//
+//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+//  This notice may not be removed from this file.
+//
+
+#import "CSamplesBaseViewController.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CPDFAViewController : CSamplesBaseViewController
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 174 - 0
Samples/Samples/PDFA/CPDFAViewController.m

@@ -0,0 +1,174 @@
+//
+//  CPDFAViewController.m
+//  Samples
+//
+//  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
+//
+//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
+//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
+//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
+//  This notice may not be removed from this file.
+//
+
+#import "CPDFAViewController.h"
+
+#import <ComPDFKit/ComPDFKit.h>
+
+//-----------------------------------------------------------------------------------------
+// The sample code illustrates how to convert PDF to PDFA format,
+// including PDFA1a, PDFA1b using API.
+//-----------------------------------------------------------------------------------------
+
+@interface CPDFAViewController ()
+
+@property (nonatomic, strong) CPDFDocument *document;
+
+@property (nonatomic, assign) BOOL isRun;
+
+@property (nonatomic, strong) NSString *commandLineStr;
+
+@property (nonatomic, strong) NSURL *convertToPDFA1aURL;
+
+@property (nonatomic, strong) NSURL *convertToPDFA1bURL;
+
+@end
+
+@implementation CPDFAViewController
+
+#pragma mark - UIViewController Methods
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    self.explainLabel.text = NSLocalizedString(@"The sample code illustrates how to convert PDF to PDFA format, including PDFA1a, PDFA1b using API.", nil);
+    
+    self.commandLineTextView.text = @"";
+    self.isRun = NO;
+    self.commandLineStr = @"";
+}
+
+#pragma mark - Samples Methods
+
+- (void)convertToPDFA1a:(CPDFDocument *)document {
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1: Convert PDF to PDFA1a format\n"];
+    
+    // Save a document in Sandbox
+    NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
+    NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"PDFA"];
+    
+    // Copy file
+    if (![[NSFileManager defaultManager] fileExistsAtPath:writeDirectoryPath])
+        [[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:writeDirectoryPath] withIntermediateDirectories:YES attributes:nil error:nil];
+    NSString *writeFilePath = [NSString stringWithFormat:@"%@/%@.pdf",writeDirectoryPath,@"ConvertToPDFA1aTest"];
+    
+    self.convertToPDFA1aURL = [NSURL fileURLWithPath:writeFilePath];
+    [document writeToURL:self.convertToPDFA1aURL];
+    
+    document = [[CPDFDocument alloc] initWithURL:self.convertToPDFA1aURL];
+    
+    [document writePDFAToURL:self.convertToPDFA1aURL withType:CPDFTypePDFA1a];
+    
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in ConvertToPDFA1aTest.pdf\n\n"];
+}
+
+- (void)convertToPDFA1b:(CPDFDocument *)document {
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Samples 1: Convert PDF to PDFA1b format\n"];
+    
+    // Save a document in Sandbox
+    NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
+    NSString *writeDirectoryPath = [NSString stringWithFormat:@"%@/%@", path, @"PDFA"];
+    
+    // Copy file
+    if (![[NSFileManager defaultManager] fileExistsAtPath:writeDirectoryPath])
+        [[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:writeDirectoryPath] withIntermediateDirectories:YES attributes:nil error:nil];
+    NSString *writeFilePath = [NSString stringWithFormat:@"%@/%@.pdf",writeDirectoryPath,@"ConvertToPDFA1bTest"];
+    
+    self.convertToPDFA1bURL = [NSURL fileURLWithPath:writeFilePath];
+    [document writeToURL:self.convertToPDFA1bURL];
+    
+    document = [[CPDFDocument alloc] initWithURL:self.convertToPDFA1bURL];
+    
+    [document writePDFAToURL:self.convertToPDFA1bURL withType:CPDFTypePDFA1a];
+    
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Done. Results saved in ConvertToPDFA1bTest.pdf\n\n"];
+}
+
+- (void)openFileWithURL:(NSURL *)url {
+    UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:@[url] applicationActivities:nil];
+        activityVC.definesPresentationContext = YES;
+    if (UIUserInterfaceIdiomPad == UI_USER_INTERFACE_IDIOM()) {
+        activityVC.popoverPresentationController.sourceView = self.openfileButton;
+        activityVC.popoverPresentationController.sourceRect = self.openfileButton.bounds;
+    }
+    [self presentViewController:activityVC animated:YES completion:nil];
+    activityVC.completionWithItemsHandler = ^(UIActivityType  _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {
+
+        if (completed) {
+            NSLog(@"Success!");
+        } else {
+            NSLog(@"Failed Or Canceled!");
+        }
+    };
+}
+
+#pragma mark - Action
+
+- (IBAction)buttonItemClick_openFile:(id)sender {
+    // Determine whether to export the document
+    if (self.isRun) {
+        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;
+            alertController.popoverPresentationController.sourceRect = self.openfileButton.bounds;
+        }
+        
+        UIAlertAction *convertToPDFA1aAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"   ConvertToPDFA1aTest.pdf   ", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            // Open CreateBookmarkTest.pdf
+            [self openFileWithURL:self.convertToPDFA1aURL];
+        }];
+        UIAlertAction *convertToPDFA1bAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"   ConvertToPDFA1bTest.pdf   ", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            // Open CreateBookmarkTest.pdf
+            [self openFileWithURL:self.convertToPDFA1bURL];
+        }];
+        
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil];
+        
+        [alertController addAction:convertToPDFA1aAction];
+        [alertController addAction:convertToPDFA1bAction];
+        [alertController addAction:cancelAction];
+        
+        [self presentViewController:alertController animated:NO completion:nil];
+    } else {
+        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;
+            alertController.popoverPresentationController.sourceRect = self.openfileButton.bounds;
+        }
+        
+        UIAlertAction *noAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"No files for this sample.", nil) style:UIAlertActionStyleDefault handler:nil];
+        
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel handler:nil];
+        
+        [alertController addAction:noAction];
+        [alertController addAction:cancelAction];
+        
+        [self presentViewController:alertController animated:NO completion:nil];
+    }
+}
+
+- (IBAction)buttonItemClick_run:(id)sender {
+    self.isRun = YES;
+    
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"Running PDFA sample...\n\n"];
+    [self convertToPDFA1a:self.document];
+    [self convertToPDFA1b:self.document];
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"\nDone!\n"];
+    self.commandLineStr = [self.commandLineStr stringByAppendingString:@"-------------------------------------\n"];
+    
+    // Refresh commandline message
+    self.commandLineTextView.text = self.commandLineStr;
+}
+
+@end