Skip to content

Commit df3cac0

Browse files
Merge pull request #22 from kaferi/master
Update to v20.1
2 parents e45d7fa + 943ef73 commit df3cac0

File tree

6 files changed

+308
-5
lines changed

6 files changed

+308
-5
lines changed

AsposePdfCloud.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Pod::Spec.new do |s|
55
s.ios.deployment_target = '10.0'
66
s.osx.deployment_target = '10.11'
77
s.tvos.deployment_target = '9.0'
8-
s.version = '19.12.0'
8+
s.version = '20.1.0'
99
s.swift_version = '4.1'
1010
s.source = { :git => 'https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift.git', :tag => s.version.to_s }
1111
s.authors = 'Aspose PDF Cloud'

AsposePdfCloud.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@
20012001
"@executable_path/Frameworks",
20022002
"@loader_path/Frameworks",
20032003
);
2004-
MARKETING_VERSION = 19.12.0;
2004+
MARKETING_VERSION = 20.1.0;
20052005
PRODUCT_BUNDLE_IDENTIFIER = com.aspose.AsposePdfCloud;
20062006
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
20072007
SKIP_INSTALL = YES;
@@ -2030,7 +2030,7 @@
20302030
"@executable_path/Frameworks",
20312031
"@loader_path/Frameworks",
20322032
);
2033-
MARKETING_VERSION = 19.12.0;
2033+
MARKETING_VERSION = 20.1.0;
20342034
PRODUCT_BUNDLE_IDENTIFIER = com.aspose.AsposePdfCloud;
20352035
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
20362036
SKIP_INSTALL = YES;

AsposePdfCloud/APIs/PdfAPI.swift

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14100,6 +14100,65 @@ open class PdfAPI {
1410014100
return requestBuilder.init(method: "POST", URLString: (urlObj?.string ?? URLString), parameters: parameters, isBody: true)
1410114101
}
1410214102

14103+
/**
14104+
Add document signature field.
14105+
14106+
- parameter name: (path) The document name.
14107+
- parameter field: (body) The field.
14108+
- parameter storage: (query) The document storage. (optional)
14109+
- parameter folder: (query) The document folder. (optional)
14110+
- parameter completion: completion handler to receive the data and the error objects
14111+
*/
14112+
open class func postSignatureField(name: String, field: SignatureField, storage: String? = nil, folder: String? = nil, completion: @escaping ((_ data: AsposeResponse?,_ error: Error?) -> Void)) {
14113+
AuthAspose.checkAuth() {
14114+
(authError) in
14115+
guard authError == nil else {
14116+
completion(nil, authError)
14117+
return
14118+
}
14119+
postSignatureFieldWithRequestBuilder(name: name, field: field, storage: storage, folder: folder).execute { (response, error) -> Void in
14120+
completion(response?.body, error);
14121+
}
14122+
}
14123+
}
14124+
14125+
14126+
/**
14127+
Add document signature field.
14128+
- POST /pdf/{name}/fields/signature
14129+
- OAuth:
14130+
- type: oauth2
14131+
- name: JWT
14132+
- examples: [{contentType=application/json, example={
14133+
"Status" : "Status",
14134+
"Code" : 0
14135+
}}]
14136+
14137+
- parameter name: (path) The document name.
14138+
- parameter field: (body) The field.
14139+
- parameter storage: (query) The document storage. (optional)
14140+
- parameter folder: (query) The document folder. (optional)
14141+
14142+
- returns: RequestBuilder<AsposeResponse>
14143+
*/
14144+
open class func postSignatureFieldWithRequestBuilder(name: String, field: SignatureField, storage: String? = nil, folder: String? = nil) -> RequestBuilder<AsposeResponse> {
14145+
var pathUrl = "/pdf/{name}/fields/signature"
14146+
pathUrl = pathUrl.replacingOccurrences(of: "{name}", with: "\(name)", options: .literal, range: nil)
14147+
let URLString = AsposePdfCloudAPI.basePath + pathUrl
14148+
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: field)
14149+
14150+
let urlObj = NSURLComponents(string: URLString)
14151+
urlObj?.queryItems = APIHelper.mapValuesToQueryItems(values:[
14152+
"storage": storage,
14153+
"folder": folder
14154+
])
14155+
14156+
14157+
let requestBuilder: RequestBuilder<AsposeResponse>.Type = AsposePdfCloudAPI.requestBuilderFactory.getBuilder()
14158+
14159+
return requestBuilder.init(method: "POST", URLString: (urlObj?.string ?? URLString), parameters: parameters, isBody: true)
14160+
}
14161+
1410314162
/**
1410414163
Split document to parts.
1410514164

@@ -20184,6 +20243,65 @@ open class PdfAPI {
2018420243
return requestBuilder.init(method: "PUT", URLString: (urlObj?.string ?? URLString), parameters: parameters, isBody: false)
2018520244
}
2018620245

20246+
/**
20247+
Replace document signature field.
20248+
20249+
- parameter name: (path) The document name.
20250+
- parameter fieldName: (path) The field name.
20251+
- parameter field: (body) The field.
20252+
- parameter storage: (query) The document storage. (optional)
20253+
- parameter folder: (query) The document folder. (optional)
20254+
- parameter completion: completion handler to receive the data and the error objects
20255+
*/
20256+
open class func putSignatureField(name: String, fieldName: String, field: SignatureField, storage: String? = nil, folder: String? = nil, completion: @escaping ((_ data: SignatureFieldResponse?,_ error: Error?) -> Void)) {
20257+
AuthAspose.checkAuth() {
20258+
(authError) in
20259+
guard authError == nil else {
20260+
completion(nil, authError)
20261+
return
20262+
}
20263+
putSignatureFieldWithRequestBuilder(name: name, fieldName: fieldName, field: field, storage: storage, folder: folder).execute { (response, error) -> Void in
20264+
completion(response?.body, error);
20265+
}
20266+
}
20267+
}
20268+
20269+
20270+
/**
20271+
Replace document signature field.
20272+
- PUT /pdf/{name}/fields/signature/{fieldName}
20273+
- OAuth:
20274+
- type: oauth2
20275+
- name: JWT
20276+
- examples: [{contentType=application/json, example=""}]
20277+
20278+
- parameter name: (path) The document name.
20279+
- parameter fieldName: (path) The field name.
20280+
- parameter field: (body) The field.
20281+
- parameter storage: (query) The document storage. (optional)
20282+
- parameter folder: (query) The document folder. (optional)
20283+
20284+
- returns: RequestBuilder<SignatureFieldResponse>
20285+
*/
20286+
open class func putSignatureFieldWithRequestBuilder(name: String, fieldName: String, field: SignatureField, storage: String? = nil, folder: String? = nil) -> RequestBuilder<SignatureFieldResponse> {
20287+
var pathUrl = "/pdf/{name}/fields/signature/{fieldName}"
20288+
pathUrl = pathUrl.replacingOccurrences(of: "{name}", with: "\(name)", options: .literal, range: nil)
20289+
pathUrl = pathUrl.replacingOccurrences(of: "{fieldName}", with: "\(fieldName)", options: .literal, range: nil)
20290+
let URLString = AsposePdfCloudAPI.basePath + pathUrl
20291+
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: field)
20292+
20293+
let urlObj = NSURLComponents(string: URLString)
20294+
urlObj?.queryItems = APIHelper.mapValuesToQueryItems(values:[
20295+
"storage": storage,
20296+
"folder": folder
20297+
])
20298+
20299+
20300+
let requestBuilder: RequestBuilder<SignatureFieldResponse>.Type = AsposePdfCloudAPI.requestBuilderFactory.getBuilder()
20301+
20302+
return requestBuilder.init(method: "PUT", URLString: (urlObj?.string ?? URLString), parameters: parameters, isBody: true)
20303+
}
20304+
2018720305
/**
2018820306
Replace document sound annotation
2018920307

AsposePdfCloudTests/FieldsTests.swift

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,140 @@ class FieldsTests: AsposePdfCloudTests {
319319
self.waitForExpectations(timeout: testTimeout, handler: nil)
320320
}
321321

322+
func testPostSignatureField() {
323+
324+
let name = "4pages.pdf"
325+
let signatureName = "33226.p12"
326+
327+
let expectation = self.expectation(description: "testPostSignatureField")
328+
329+
let signature = Signature(
330+
signaturePath: "\(self.tempFolder)/\(signatureName)",
331+
signatureType: SignatureType.pkcs7,
332+
password: "sIikZSmz",
333+
appearance: nil,
334+
reason: nil,
335+
contact: "test@mail.ru",
336+
location: "Ukraine",
337+
visible: true,
338+
rectangle: Rectangle(LLX: 100, LLY: 100, URX: 0, URY: 0),
339+
formFieldName: "Signature1",
340+
authority: "Sergey Smal",
341+
date: "08/01/2012 12:15:00.000 PM",
342+
showProperties: false,
343+
timestampSettings: nil,
344+
isValid: nil,
345+
customAppearance: nil)
346+
347+
let field = SignatureField(
348+
links: nil,
349+
partialName: "Sign1",
350+
rect: Rectangle(LLX: 100, LLY: 100, URX: 0, URY: 0),
351+
value: nil,
352+
pageIndex: 1,
353+
height: nil,
354+
width: nil,
355+
zIndex: nil,
356+
isGroup: nil,
357+
parent: nil,
358+
isSharedField: nil,
359+
flags: nil,
360+
color: nil,
361+
contents: nil,
362+
margin: nil,
363+
highlighting: nil,
364+
horizontalAlignment: nil,
365+
verticalAlignment: nil,
366+
border: nil,
367+
signature: signature)
368+
369+
uploadFiles(names: [name, signatureName]) {
370+
371+
PdfAPI.postSignatureField(name: name, field: field, folder: self.tempFolder) {
372+
(response, error) in
373+
guard error == nil else {
374+
XCTFail("error testPostSignatureField: " + (error.debugDescription))
375+
return
376+
}
377+
378+
if let response = response {
379+
XCTAssertEqual(response.code, self.codeOk)
380+
381+
expectation.fulfill()
382+
}
383+
}
384+
}
385+
386+
self.waitForExpectations(timeout: testTimeout, handler: nil)
387+
}
388+
389+
func testPutSignatureField() {
390+
391+
let name = "adbe.x509.rsa_sha1.valid.pdf"
392+
let signatureName = "33226.p12"
393+
394+
let expectation = self.expectation(description: "testPutSignatureField")
395+
396+
let signature = Signature(
397+
signaturePath: "\(self.tempFolder)/\(signatureName)",
398+
signatureType: SignatureType.pkcs7,
399+
password: "sIikZSmz",
400+
appearance: nil,
401+
reason: nil,
402+
contact: "test@mail.ru",
403+
location: "Ukraine",
404+
visible: true,
405+
rectangle: Rectangle(LLX: 100, LLY: 100, URX: 0, URY: 0),
406+
formFieldName: "Signature1",
407+
authority: "Sergey Smal",
408+
date: "08/01/2012 12:15:00.000 PM",
409+
showProperties: false,
410+
timestampSettings: nil,
411+
isValid: nil,
412+
customAppearance: nil)
413+
414+
let field = SignatureField(
415+
links: nil,
416+
partialName: "Sign1",
417+
rect: Rectangle(LLX: 100, LLY: 100, URX: 0, URY: 0),
418+
value: nil,
419+
pageIndex: 1,
420+
height: nil,
421+
width: nil,
422+
zIndex: nil,
423+
isGroup: nil,
424+
parent: nil,
425+
isSharedField: nil,
426+
flags: nil,
427+
color: nil,
428+
contents: nil,
429+
margin: nil,
430+
highlighting: nil,
431+
horizontalAlignment: nil,
432+
verticalAlignment: nil,
433+
border: nil,
434+
signature: signature)
435+
436+
uploadFiles(names: [name, signatureName]) {
437+
438+
PdfAPI.putSignatureField(name: name, fieldName: "Signature1", field: field, folder: self.tempFolder) {
439+
(response, error) in
440+
guard error == nil else {
441+
XCTFail("error testPutSignatureField: " + (error.debugDescription))
442+
return
443+
}
444+
445+
if let response = response {
446+
XCTAssertEqual(response.code, self.codeOk)
447+
448+
expectation.fulfill()
449+
}
450+
}
451+
}
452+
453+
self.waitForExpectations(timeout: testTimeout, handler: nil)
454+
}
455+
322456
func testGetDocumentTextBoxFields() {
323457

324458
let name = "FormDataTextBox.pdf"

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Edit assembly info of a PDF document online https://products.aspose.app/pdf/asse
1717
$ gem install cocoapods
1818
```
1919

20-
> CocoaPods 1.1+ is required to build AsposePdfCloud 19.12+.
20+
> CocoaPods 1.1+ is required to build AsposePdfCloud 20.1+.
2121
2222
To integrate AsposePdfCloud into your Xcode project using CocoaPods, specify it in your `Podfile`:
2323

@@ -27,7 +27,7 @@ platform :ios, '10.0'
2727
use_frameworks!
2828

2929
target '<Your Target Name>' do
30-
pod 'AsposePdfCloud', '~> 19.12'
30+
pod 'AsposePdfCloud', '~> 20.1'
3131
end
3232
```
3333

@@ -318,6 +318,7 @@ Class | Method | HTTP request | Description
318318
*PdfApi* | [**postPageUnderlineAnnotations**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#postPageUnderlineAnnotations) | **POST** /pdf/\{name}/pages/\{pageNumber}/annotations/underline | Add document page underline annotations.
319319
*PdfApi* | [**postPopupAnnotation**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#postPopupAnnotation) | **POST** /pdf/\{name}/annotations/\{annotationId}/popup | Add document popup annotations.
320320
*PdfApi* | [**postRadioButtonFields**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#postRadioButtonFields) | **POST** /pdf/\{name}/fields/radiobutton | Add document RadioButton fields.
321+
*PdfApi* | [**postSignatureField**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#postSignatureField) | **POST** /pdf/\{name}/fields/signature | Add document signature field.
321322
*PdfApi* | [**postSignDocument**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#postSignDocument) | **POST** /pdf/\{name}/sign | Sign document.
322323
*PdfApi* | [**postSignPage**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#postSignPage) | **POST** /pdf/\{name}/pages/\{pageNumber}/sign | Sign page.
323324
*PdfApi* | [**postSplitDocument**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#postSplitDocument) | **POST** /pdf/\{name}/split | Split document to parts.
@@ -412,6 +413,7 @@ Class | Method | HTTP request | Description
412413
*PdfApi* | [**putScreenAnnotationDataExtract**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#putScreenAnnotationDataExtract) | **PUT** /pdf/\{name}/annotations/screen/\{annotationId}/data/extract | Extract document screen annotation content to storage
413414
*PdfApi* | [**putSearchableDocument**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#putSearchableDocument) | **PUT** /pdf/\{name}/ocr | Create searchable PDF document. Generate OCR layer for images in input PDF document.
414415
*PdfApi* | [**putSetProperty**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#putSetProperty) | **PUT** /pdf/\{name}/documentproperties/\{propertyName} | Add/update document property.
416+
*PdfApi* | [**putSignatureField**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#putSignatureField) | **PUT** /pdf/\{name}/fields/signature/\{fieldName} | Replace document signature field.
415417
*PdfApi* | [**putSoundAnnotation**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#putSoundAnnotation) | **PUT** /pdf/\{name}/annotations/sound/\{annotationId} | Replace document sound annotation
416418
*PdfApi* | [**putSoundAnnotationDataExtract**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#putSoundAnnotationDataExtract) | **PUT** /pdf/\{name}/annotations/sound/\{annotationId}/data/extract | Extract document sound annotation content to storage
417419
*PdfApi* | [**putSquareAnnotation**](https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-swift/tree/master/docs/PdfApi.md#putSquareAnnotation) | **PUT** /pdf/\{name}/annotations/square/\{annotationId} | Replace document square annotation

0 commit comments

Comments
 (0)