Foxit Mobile PDF SDK-強大的UI Extensions(如何實現PDF的填表,超鏈接,搜索,標註。。。)

本人也在學習中,前面的文章基本是基礎的不能再基礎的,菜鳥得不能再菜鳥啦。

現在的這篇也是菜鳥級別的,基本不用寫啥代碼,不過會讓你瞬間覺得你的程序高大上了,依然是幾行的代碼,不過你的App的功能會瞬間強大起來。。。。

這些代碼可以讓你瞬間擁有了強大的填表,標註,搜索,鏈接響應。。。等等曾經讓人覺得複雜無比的功能。

先再附上這個產品的相關介紹頁面:

產品頁面--最近剛剛發佈了新版本2.0

http://www.foxitsdk.com/products/mobile-pdf-sdk/

下載申請

https://www.foxitsoftware.com/products/sdk/register.php?product=MobilePDFSDK

注意:最好用公司郵箱申請哦,如果用163之類的申請,可能會收不到郵件哦!

好了,本文正式開工了。

關於UI Extensions Component

官網的介紹如下:

"The UI Extensions Component builds on the View Control, providing a customizable user interface with built-in tools for text selection, markup annotations, night mode, bookmark navigation and full-text searching. The UI Extensions Component is provided as a compiled component for rapid integration, and for complete flexibility source code is also provided which allows developers to customize the default user interface and control precisely the functionality of the default Tools."

英文看的是不是頭大?簡單一句話,可以理解爲這個是一個帶了一堆內置帶Ui工具的組件。幾乎包含實現一個普通閱讀器應用層的所有的時間
一切都不重要,重要的是,這是開源的~~~,後面深入學習後,就知道怎麼修改了。。。從功能看,應該是強大的代碼~~懂得珍惜的人,一定如獲至寶。

說明:

1.本文是 Foxit Mobile PDF SDK嚐鮮-IOS篇(2)- 顯示一個PDF文件 的續集。所有,如果你想測試下面的步驟,請先看完顯示PDF的文章再繼續哦
2.關於URL類型的鏈接支持,iOS平臺2.0纔開始支持的,1.0是不支持的。

UIExtensions 導入工程

導入libFoxitRDKUIExtensions.a

選中工程右鍵選擇Add Files to "AmyTest" ,選擇SDK包中的libFoxitRDKUIExtensions.a , Add加入



接着在Build Settings裏面的Other Linker Flags加入-force_load libFoxitRDKUIExtensions.a




當然,這個產品還是初級階段,期待後面的版本吧,UI Extensions的接口不夠靈活,啓用/禁用鏈接,等等一些功能的Enable/Disable。。。需要去修改UI extension的相關代碼,或者把不需要的註釋掉纔可以。

現在才2.0,相信不久的將來,這些細節都將得到完善。。。。期待吧~~~

把UIExtensions的資源以及頭文件導入

頭文件只需要“UIExtensionsManager.h”,右鍵Add Files to "AmyTest" 選擇ibs/uiextensions_src/uiextensions目錄下的“UIExtensionsManager.h”.

導入資源,最簡單的辦法我把lib/uiextension_src/uiextension的目錄拷貝到AmyTest目錄下。


接着導入資源到工程,選中工程,右鍵Add Files to "AmyTest" 選擇uiextension目錄下的“Resources"目錄。


加入之後工程長這樣


更名ViewController.m 爲ViewController.mm



敲代碼


很簡單,只需要初始化UIExtension就好啦,爲了方便,我就繼續加入到了”ViewController.mm”

首先在文件的開始部分導入"UIExtensionsManager.h"

#import "UIExtensionsManager.h"

接着UIExtensions初始化代碼加入到之前顯示的代碼之後。

    UIExtensionsManager* extensionsManager;
   extensionsManager = [[UIExtensionsManager alloc] initWithPDFViewControl:myTestViewCtrl];
    myTestViewCtrl.extensionsManager = extensionsManager;

加入這些代碼之後,你的APP就高大上了不少,填表,鏈接響應的功能就自然有了,如下圖,超鏈接會被用黃色高亮起來。點擊就會進行相應的跳轉了。

表單也可以進行填寫啦。


share下整個代碼文件吧:

#import "ViewController.h"
#import <FoxitRDK/FSPDFObjC.h>
#import <FoxitRDK/FSPDFViewControl.h>
#import "UIExtensionsManager.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSString* sn = @"*****";
    NSString* unlock = @"*****";
    enum FS_ERRORCODE eRet = [FSLibrary init:sn key:unlock];
    if (e_errSuccess != eRet) {
        return;
    }
    //load doc
    NSString* docPath= [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"pdf"];
    FSPDFDoc* doc = [FSPDFDoc createFromFilePath:docPath];
    
    if (e_errSuccess!=[doc load:nil]) {
        return;
    }
    
    //init PDFViewerCtrl
    FSPDFViewCtrl* myTestViewCtrl;
    myTestViewCtrl = [[FSPDFViewCtrl alloc] initWithFrame:[self.view bounds]];
    [myTestViewCtrl gotoPage:3 animated:true];
    [myTestViewCtrl setDoc:doc];
    [self.view addSubview:myTestViewCtrl];
    UIExtensionsManager* extensionsManager;
   extensionsManager = [[UIExtensionsManager alloc] initWithPDFViewControl:myTestViewCtrl];
    myTestViewCtrl.extensionsManager = extensionsManager;

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end



接着我還想有標註,想做個Outline面板,想添加標註,要怎麼做啊?

同樣的簡單,用戶手冊裏面都有,傻瓜式的教學哦

請看:

http://www.foxitsdk.com/sdk-docs/

http://www.foxitsdk.com/docs/mobile-pdf-sdk/developer_guide_ios.pdf

http://www.foxitsdk.com/docs/mobile-pdf-sdk/api_reference_ios/html/index.html


2.5.6章節會告訴你的。

前兩天剛剛發佈的版本,集成了大量的標註工具,並支持了填表,哈,下面的截圖會告訴你支持了啥




歡迎技術交流,可以私信我哈~~

發佈了18 篇原創文章 · 獲贊 11 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章