2017-10-13 50 views
1

我正在實施顯示和編輯pdf的iOS和Mac應用程序。PDFTron mac實現

  • 使用下面提供的代碼完成iOS版本的實現。
  • 問題是mac版本,它不包含顯示和編輯pdf所需的PTPDFViewCtrl和ToolManager類。

任何人有任何經驗使用他們的等效類的mac實現或建議mac實現?

#pragma mark - PDFKit 
-(void)initialConfig { 

#warning MISSING PDFTRon license key 
    // initialize PDFNet 
    [PTPDFNet Initialize:@""]; 

    PTPDFViewCtrl *ctrl = [PTPDFViewCtrl new]; 
    CGFloat offset = 20; 
    ctrl.frame = CGRectMake(0, offset, self.view.frame.size.width, self.view.frame.size.height - offset); 
    [ctrl SetBackgroundColor:0 g:0 b:0 a:0]; 
    [ctrl SetHighlightFields:YES]; 
self.view.backgroundColor = [UIColor lightGrayColor]; 
    [self.view addSubview:ctrl]; 

    // open the PDF document included in the bundle in the PTPDFViewCtrl 
    PTPDFDoc *doc = [[PTPDFDoc alloc]initWithFilepath:self.viewModel.getFilePath]; 
    [ctrl SetDoc:doc]; 
    self.viewModel.doc = doc; 

    [ctrl setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth]; 

    // add the toolmanager (used to implement text selection, annotation editing, etc. 
    ToolManager *toolManager = [[ToolManager alloc] initWithPDFViewCtrl:ctrl]; 
    [toolManager changeTool:[PanTool self]]; 
    ctrl.toolDelegate = toolManager; 
} 

非常感謝您的任何幫助。 Matti

回答

1

爲了演示的目的,我們的PDFNetCMac C/C++下載中包含了一個Java SWING示例項目,但不支持此示例。它使用PDFView類,並展示了一些集成的基礎知識。例如,示例不支持註釋。

同樣,還有一個C++ Windows MFC示例,一些客戶用它作爲與跨平臺框架(如Qt)集成的指南。

另一種選擇是使用PDF WebViewer,它需要將用戶界面移動到本地macOS應用程序的瀏覽器元素中,但WebViewer包含完整的查看體驗,包括表單填充和註釋。