Foxit PDF SDK
FSConnectedPDF Class Reference
Inheritance diagram for FSConnectedPDF:
FSBase

Instance Methods

(FSErrorCode- convertToCDRM:wrapper_path:file_name:
 Convert the loaded document to a ConnectedPDF DRM document.
More...
 
(FSErrorCode- convertToCDRMWithReaderCallback:wrapper_file_read:file_name:
 Convert the loaded document to a ConnectedPDF DRM document.
More...
 
(FSErrorCode- convertToCPDF:file_name:
 Convert the loaded document to a ConnectedPDF document.
More...
 
(NSString *) - getACL
 Get ACL of a ConnectedPDF DRM document.
More...
 
(NSString *) - getContentKey
 Get the content key if the loaded document is a ConnectedPDF DRM document.
More...
 
(FSPDFDoc *) - getDocument
 Get the associated PDF document object.
More...
 
(NSString *) - getDocURI
 Get the ConnectedPDF document URI from the loaded document.
More...
 
(NSString *) - getEndpoint
 Get the ConnectedPDF document endpoint from the loaded document.
More...
 
(NSString *) - getOwnerEmail
 Get the ConnectedPDF document owner email.
More...
 
(NSString *) - getOwnerName
 Get the ConnectedPDF document owner name.
More...
 
(NSString *) - getVersionID
 Get the ConnectedPDF document version ID from the loaded document.
More...
 
(id) - initWithClientid:user_token:content_key:type:document:
 Constructor, with parameters and a PDF document object.
More...
 
(id) - initWithClientid:user_token:content_key:type:file_path:
 Constructor, with parameters and from an existing PDF file path.
More...
 
(id) - initWithClientid:user_token:content_key:type:file_read:
 Constructor, with parameters and a FSFileReaderCallback object.
More...
 
(id) - initWithConnected_pdf:
 Constructor, with another FSConnectedPDF object.
More...
 
(BOOL) - isCDRM
 Check whether the loaded document is a ConnectedPDF DRM document or not.
More...
 
(BOOL) - isCPDF
 Check whether the loaded document is a ConnectedPDF document or not.
More...
 
(BOOL) - isEmpty
 Check whether current object is empty or not.
More...
 
(BOOL) - isOwner
 Check whether current user is the owner.
More...
 
(NSString *) - refreshVersionID
 Refresh the ConnectedPDF document version ID from the loaded document.
More...
 
(FSErrorCode- removeCDRM
 Remove the ConnectedPDF DRM protection of a ConnectedPDF document.
More...
 
(BOOL) - saveAs:
 Save the current ConnectedPDF document as another PDF file.
More...
 
(BOOL) - saveAsWithWriterCallback:
 Save the current ConnectedPDF document as another PDF file.
More...
 
(FSErrorCode- setACL:
 Set ACL of a ConnectedPDF DRM document.
More...
 

Class Methods

(NSString *) + getClientIDFromServer:client_info:
 Apply for a client id from ConnectedPDF server using the input client info.
More...
 
(NSString *) + getDocURIWithFilePath:
 Get the ConnectedPDF document URI from the PDF path.
More...
 
(NSString *) + getUserTokenFromServer:user_email:password:
 Get the user token from ConnectedPDF server.
More...
 

Properties

NSString * userToken
 Get or Set the user token.

 

Detailed Description

Class FSConnectedPDF offers following functions,

  • Convert a normal PDF document to a ConnectedPDF document.
  • Convert a normal PDF document or a ConnectedPDF document to a ConnectedPDF DRM document.
  • Decrypt and configure the ACL of ConnectedPDF DRM.


Method Documentation

◆ convertToCDRM:wrapper_path:file_name:()

- (FSErrorCode) convertToCDRM: (NSString *)  endpoint
wrapper_path: (NSString *)  wrapper_path
file_name: (NSString *)  file_name 

Convert the loaded document to a ConnectedPDF DRM document.

When the loaded document is converted to a ConnectedPDF DRM document, please use function FSConnectedPDF::saveAs: to save it.

Parameters
[in]endpointThe input ConnectedPDF server host address. For example, https://www-fz02.connectedpdf.com.
[in]wrapper_pathA path of an existing PDF file.
[in]file_nameThe file name used by ConnectedPDF server. If this is an empty string, "Unknown.pdf" will be used as the file name by default
Returns
FSErrSuccess means success.
FSErrIsAlreadyCDRM means the loaded document has been a ConnectedPDF DRM document.
For other error code value, please refer to values starting from FSErrSuccess for more details.

◆ convertToCDRMWithReaderCallback:wrapper_file_read:file_name:()

- (FSErrorCode) convertToCDRMWithReaderCallback: (NSString *)  endpoint
wrapper_file_read: (id<FSFileReaderCallback>)  wrapper_file_read
file_name: (NSString *)  file_name 

Convert the loaded document to a ConnectedPDF DRM document.

When the loaded document is converted to a ConnectedPDF DRM document, please use function FSConnectedPDF::saveAs: to save it.

Parameters
[in]endpointThe input ConnectedPDF server host address. For example, https://www-fz02.connectedpdf.com.
[in]wrapper_file_readA FSFileReaderCallback object which is implemented by user to save a PDF document.
[in]file_nameThe file name used by ConnectedPDF server. If this is an empty string, "Unknown.pdf" will be used as the file name by default
Returns
FSErrSuccess means success.
FSErrIsAlreadyCDRM means the loaded document has been a ConnectedPDF DRM document.
For other error code value, please refer to values starting from FSErrSuccess for more details.

◆ convertToCPDF:file_name:()

- (FSErrorCode) convertToCPDF: (NSString *)  endpoint
file_name: (NSString *)  file_name 

Convert the loaded document to a ConnectedPDF document.

When the loaded document is converted to a ConnectedPDF document, please use function FSConnectedPDF::saveAs: to save it.

Parameters
[in]endpointThe input ConnectedPDF server host address. For example, https://www-fz02.connectedpdf.com.
[in]file_nameThe file name used by ConnectedPDF server. If this is an empty string, "Unknown.pdf" will be used as the file name by default
Returns
FSErrSuccess means success.
FSErrIsAlreadyCPDF means the loaded document has been a ConnectedPDF document.
For other error code value, please refer to values starting from FSErrSuccess for more details.

◆ getACL()

- (NSString *) getACL

Get ACL of a ConnectedPDF DRM document.

The owner can get all the user's ACL; otherwise, the current user can get its own ACL. If the loaded document is not a ConnectedPDF DRM document, this function will throw exception FSErrNotCDRM.

Returns
The ACL data string. The data is a JSON string. The JSON string is an array of all the user's ACL. Every element of the array is one user's ACL. The format is described as follows,
    [
      {
        Control the specified pages to be hidden.
        "accessPages" :
        {
          The page indexes to be hidden. For example, [ 1, [2,10],12 ].
          "Pages" : [],
          The content cover over the hidden pages.
          "wrapperContent" : null,
          The picture cover over the hidden pages. Cannot support now. Just leave it empty.
          "wrapperPic" : null
        },
        The PDF standard permission array. The value is hex. The values can be 4,8,10,20,100,200,400,800.
        Please refer to values starting from  for more information.
        "decodePermission" : [ 8, 10 ],
        Limit device to open the document.
        "deviceLimit" :
        {
          The devices has opened the document.
          "appList" : [],
          No more device can open the document.
          "isLimit" : 0,
          The permitted device count to open the document.
          "limitNum" : 0
        },
        Whether the ACL is for everyone or not.
        "everyone" : 0,
        Whether the user has full control permission.
        "fullControl" : 0,
        The grout ID.
        "groupID" : "",
        The grout name.
        "groupName" : "",
        Whether the ACL is for a group or not.
        "isGroup" : 0,
        Whether the ACL has been revoked.
        "isRevoke" : 0,
        Whether the user can open the document offline. 0=Never 1=By Days 2=Always.
        "offline" : 0,
        The permitted offline days.
        "offlineDuration" : 0,
        Whether set the online expiration date. 0=Never 1=By Days 2=By Date.
        "online" : 0,
        Expiration date. For example, "2017-01-01 01:59:59".
        "onlineDuration" : "",
        Expiration days.
        "onlineDurationDays" : 0,
        The PDF standard permission. The value is decimal. It's the combination of the hex values
    4,8,10,20,100,200,400,800.
        Please refer to values starting from  for more information.
        "permission" : 312,
        The user info.
        "userAttribute" :
        {
          The domain the user belongs to.
          "Domain" : "",
          The user ID.
          "cUserID" : "58197659c2dcf1c7143febce",
          The user email.
          "userEmail" : "65908769@qq.com"
        }
      }
    ]
    

◆ getClientIDFromServer:client_info:()

+ (NSString *) getClientIDFromServer: (NSString *)  endpoint
client_info: (FSClientInfo*)  client_info 

Apply for a client id from ConnectedPDF server using the input client info.

The client id represents a ConnectedPDF client running on a device. The client ID is used to create a FSConnectedPDF object. It is required for converting normal PDF to ConnectedPDF. The client should apply for a client id once, then cache it and reuse it. This function may throw exception FSErrCanNotConnectToServer.

Parameters
[in]endpointThe input ConnectedPDF server host address. For example, https://www-fz02.connectedpdf.com.
[in]client_infoThe input client information used to apply for a client id from ConnectedPDF server.
Returns
The client ID string. If the returned string is not an empty string, that means success.
Note
If module "ConnectedPDF" is not defined in the license information which is used in function FSLibrary::initialize:key:, that means user has no right in using ConnectedPDF related functions and this function will throw exception FSErrInvalidLicense.

◆ getContentKey()

- (NSString *) getContentKey

Get the content key if the loaded document is a ConnectedPDF DRM document.

Returns
The content key of ConnectedPDF DRM document.

◆ getDocument()

- (FSPDFDoc *) getDocument

Get the associated PDF document object.

The returned PDF document object can be edited. If the loaded document is a ConnectedPDF DRM document, user should save it by function FSConnectedPDF::saveAs:; otherwise, the saved document will be corrupted.

Returns
The associated PDF document object.

◆ getDocURI()

- (NSString *) getDocURI

Get the ConnectedPDF document URI from the loaded document.

Returns
The ConnectedPDF document URI. If the returned string is an empty string, that means the loaded document is not a valid ConnectedPDF document.

◆ getDocURIWithFilePath:()

+ (NSString *) getDocURIWithFilePath: (NSString *)  file_path

Get the ConnectedPDF document URI from the PDF path.

Every ConnectedPDF document or ConnectedPDF DRM document has the document URI. It is the unique identification of the ConnectedPDF document or ConnectedPDF DRM document.

Parameters
[in]file_pathA path of an existing PDF file.
Returns
The ConnectedPDF document URI. If the returned string is an empty string, that means the input document is not a valid ConnectedPDF document.
Note
If module "ConnectedPDF" is not defined in the license information which is used in function FSLibrary::initialize:key:, that means user has no right in using ConnectedPDF related functions and this function will throw exception FSErrInvalidLicense.

◆ getEndpoint()

- (NSString *) getEndpoint

Get the ConnectedPDF document endpoint from the loaded document.

Returns
The ConnectedPDF document endpoint. If the returned string is an empty string, that means the loaded document is not a valid ConnectedPDF document.

◆ getOwnerEmail()

- (NSString *) getOwnerEmail

Get the ConnectedPDF document owner email.

Returns
The ConnectedPDF document owner email.

◆ getOwnerName()

- (NSString *) getOwnerName

Get the ConnectedPDF document owner name.

Returns
The ConnectedPDF document owner name.

◆ getUserTokenFromServer:user_email:password:()

+ (NSString *) getUserTokenFromServer: (NSString *)  endpoint
user_email: (NSString *)  user_email
password: (NSString *)  password 

Get the user token from ConnectedPDF server.

A user token should be gotten before accessing ConnectedPDF web service. The client can get the user token once, then cache it and reuse it. This function may throw exception FSErrCanNotConnectToServer.

Parameters
[in]endpointThe input ConnectedPDF server host address. For example, https://www-fz02.connectedpdf.com.
[in]user_emailThe input user email.
[in]passwordThe input user password.
Returns
The user token string. If the returned string is not an empty string, that means success.
Note
If module "ConnectedPDF" is not defined in the license information which is used in function FSLibrary::initialize:key:, that means user has no right in using ConnectedPDF related functions and this function will throw exception FSErrInvalidLicense.

◆ getVersionID()

- (NSString *) getVersionID

Get the ConnectedPDF document version ID from the loaded document.

Returns
The ConnectedPDF document version ID. If the returned string is an empty string, that means the loaded document is not a valid ConnectedPDF document.

◆ initWithClientid:user_token:content_key:type:document:()

- (id) initWithClientid: (NSString *)  clientid
user_token: (NSString *)  user_token
content_key: (NSString *)  content_key
type: (FSConnectedPDFEncryptType type
document: (FSPDFDoc*)  document 

Constructor, with parameters and a PDF document object.

The constructed FSConnectedPDF object can be converted to a ConnectedPDF document or a ConnectedPDF DRM document.

Parameters
[in]clientidA client ID whcih is created by function FSConnectedPDF::getClientIDFromServer:client_info:.
[in]user_tokenA user token is created by function FSConnectedPDF::getUserTokenFromServer:user_email:password:.
[in]content_keyIf the client has cached the content key, just input the cached key to decrypt ConnectedPDF DRM document. Otherwise, set content_key as nil, and FSConnectedPDF object will apply for the content key from server.
[in]typeEncryption algorithm. Please refer to values starting from FSConnectedPDFEncryptTypeAES and this should be one of these values.
[in]documentA valid PDF document object which represents a normal PDF document.
Note
If module "ConnectedPDF" is not defined in the license information which is used in function FSLibrary::initialize:key:, that means user has no right in using ConnectedPDF related functions and this constructor will throw exception FSErrInvalidLicense.

◆ initWithClientid:user_token:content_key:type:file_path:()

- (id) initWithClientid: (NSString *)  clientid
user_token: (NSString *)  user_token
content_key: (NSString *)  content_key
type: (FSConnectedPDFEncryptType type
file_path: (NSString *)  file_path 

Constructor, with parameters and from an existing PDF file path.

A FSConnectedPDF object can be constructed to load a normal PDF document, or a ConnectedPDF document, or a ConnectedPDF DRM document. If current document is a normal PDF document, it can be converted to a ConnectedPDF document or a ConnectedPDF DRM document. If current document is a ConnectedPDF document, it can be convert to a ConnectedPDF DRM document.

Parameters
[in]clientidA client ID whcih is created by function FSConnectedPDF::getClientIDFromServer:client_info:.
[in]user_tokenA user token is created by function FSConnectedPDF::getUserTokenFromServer:user_email:password:.
[in]content_keyIf the client has cached the content key, just input the cached key to decrypt ConnectedPDF DRM document. Otherwise, set content_key with an empty string, and FSConnectedPDF object will apply for the content key from server.
[in]typeEncryption algorithm. Please refer to values starting from FSConnectedPDFEncryptTypeAES and this should be one of these values.
[in]file_pathA path of an existing PDF file.
Note
If module "ConnectedPDF" is not defined in the license information which is used in function FSLibrary::initialize:key:, that means user has no right in using ConnectedPDF related functions and this constructor will throw exception FSErrInvalidLicense.

◆ initWithClientid:user_token:content_key:type:file_read:()

- (id) initWithClientid: (NSString *)  clientid
user_token: (NSString *)  user_token
content_key: (NSString *)  content_key
type: (FSConnectedPDFEncryptType type
file_read: (id<FSFileReaderCallback>)  file_read 

Constructor, with parameters and a FSFileReaderCallback object.

A FSConnectedPDF object can be constructed to load a normal PDF document, or a ConnectedPDF document, or a ConnectedPDF DRM document. If current document is a normal PDF document, it can be converted to a ConnectedPDF document or a ConnectedPDF DRM document. If current document is a ConnectedPDF document, it can be convert to a ConnectedPDF DRM document.

Parameters
[in]clientidA client ID whcih is created by function FSConnectedPDF::getClientIDFromServer:client_info:.
[in]user_tokenA user token is created by function FSConnectedPDF::getUserTokenFromServer:user_email:password:.
[in]content_keyIf the client has cached the content key, just input the cached key to decrypt ConnectedPDF DRM document. Otherwise, set content_key with an empty string, and FSConnectedPDF object will apply for the content key from server.
[in]typeEncryption algorithm. Please refer to values starting from FSConnectedPDFEncryptTypeAES and this should be one of these values.
[in]file_readA FSFileReaderCallback object which is implemented by user to load a PDF document. It should not be nil.
Note
If module "ConnectedPDF" is not defined in the license information which is used in function FSLibrary::initialize:key:, that means user has no right in using ConnectedPDF related functions and this constructor will throw exception FSErrInvalidLicense.

◆ initWithConnected_pdf:()

- (id) initWithConnected_pdf: (FSConnectedPDF*)  connected_pdf

Constructor, with another FSConnectedPDF object.

Parameters
[in]connected_pdfAnother FSConnectedPDF object

◆ isCDRM()

- (BOOL) isCDRM

Check whether the loaded document is a ConnectedPDF DRM document or not.

Returns
YES means the loaded document is a ConnectedPDF DRM document, while NO means the loaded document is not a ConnectedPDF DRM document.

◆ isCPDF()

- (BOOL) isCPDF

Check whether the loaded document is a ConnectedPDF document or not.

Returns
YES means the loaded document is a ConnectedPDF document, while NO means the loaded document is not a ConnectedPDF document.

◆ isEmpty()

- (BOOL) isEmpty

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
YES means current object is empty, while NO means not.

◆ isOwner()

- (BOOL) isOwner

Check whether current user is the owner.

Returns
YES means current user is the owner, while NO means current user is not the owner.

◆ refreshVersionID()

- (NSString *) refreshVersionID

Refresh the ConnectedPDF document version ID from the loaded document.

Returns
The ConnectedPDF document new version ID. If the returned string is an empty string, that means the loaded document is not a valid ConnectedPDF document.

◆ removeCDRM()

- (FSErrorCode) removeCDRM

Remove the ConnectedPDF DRM protection of a ConnectedPDF document.

Only the owner has the permission to remove the ConnectedPDF DRM protection. When the ConnectedPDF DRM protection is removed, function FSConnectedPDF::saveAs: can be used to save it.

Returns
FSErrSuccess means success.
FSErrNotCDRM means the loaded document is not a ConnectedPDF DRM document.
For other error code value, please refer to values starting from FSErrSuccess for more details.

◆ saveAs:()

- (BOOL) saveAs: (NSString *)  file_path

Save the current ConnectedPDF document as another PDF file.

If the loaded document is a ConnectedPDF DRM document, the document can be saved as only by this funcction; otherwise the saved document will be corrupted.

Parameters
[in]file_pathA path for the new saved PDF file. It should not be an empty string.
Returns
YES means the saving is successfully finished, while NO means failure.

◆ saveAsWithWriterCallback:()

- (BOOL) saveAsWithWriterCallback: (id<FSFileWriterCallback>)  file_write

Save the current ConnectedPDF document as another PDF file.

If the loaded document is a ConnectedPDF DRM document, the document can be saved as only by this funcction; otherwise the saved document will be corrupted.

Parameters
[in]file_writeA FSFileWriterCallback object which is implemented by user to do the saving.
Returns
YES means the saving is successfully finished, while NO means failure.

◆ setACL:()

- (FSErrorCode) setACL: (NSString *)  acl

Set ACL of a ConnectedPDF DRM document.

Only the owner has the permission to set ACL. This function will revoke all the ACL of the ConnectedPDF DRM document first, and then apply the new ACL.

Parameters
[in]aclThe input ACL data. The data is a JSON string. "userList" is an array of all the user's ACL. Every element of "userList" is one user's ACL. The format is described as follows,
    {
      "userList":
      [
        {
          The user email.
          "userEmail": "fz02_50@qq.com",

The grout ID. Cannot support now. Just leave it empty. "groupId": "",

          Whether the ACL is for a group or not. Cannot support now. Just leave it 0.
          "isGroup": "0",
          Whether the ACL is for everyone or not.
          "everyone": "0",
          Whether the user has full control permission.
          "fullControl": "0",
          The PDF standard permission array. The value is hex. The values can be 4,8,10,20,100,200,400,800.
          Please refer to values starting from  for more information.
          "permission": [4],
          Whether the user can open the document offline. 0=Never 1=By Days 2=Always.
          "offline": "0",
          The permitted offline days.
          "offlineDays": 0,
          Whether set the online expiration date. 0=Never 1=By Days 2=By Date.
          "online": "0",
          Expiration date. For example, "2017-01-01 01:59:59".
          "onlineDate": "",
          Expiration days.
          "onlineDays": "0",
          The permitted device count to open the document.
          "deviceLimit": "0",
          Control the specified pages to be hidden.
          "accessPages":
          {
            The content cover over the hidden pages.
            "wrapperContent": "",
            The picture cover over the hidden pages. Cannot support now. Just leave it empty.
            "wrapperPic": "",
            The page indexes to be hidden. For example, [ 1, [2,10],12 ].
            "Pages": [0]
          }
        }
      ]
    }
    
Returns
FSErrSuccess means success.
FSErrInvalidACL means the input ACL data is invalid.
FSErrNotCDRM means the loaded document is not a ConnectedPDF DRM document.
For other error code value, please refer to values starting from FSErrSuccess for more details.