Skip to content

Commit 0ab0477

Browse files
authored
Merge pull request #84 from aspose-pdf-cloud/develop
update to 25.6
2 parents 8d7f894 + d4ffba6 commit 0ab0477

19 files changed

+309
-37
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ These SDKs are now fully supported. If you have any questions, see any bugs or h
99

1010
Extract Text & Images of a PDF document online https://products.aspose.app/pdf/parser.
1111

12-
## Enhancements in Version 25.5
13-
- Add a method for comparing pdf files.
12+
## Enhancements in Version 25.6
13+
- Develop Rotate Document Pages method.
1414
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
1515

1616
## Installation

api_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (c *APIClient) prepareRequest (
176176

177177
// set custom header
178178
headerParams["x-aspose-client"] = "go sdk"
179-
headerParams["x-aspose-client-version"] = "25.5.0"
179+
headerParams["x-aspose-client-version"] = "25.6.0"
180180

181181
// Detect postBody type and post.
182182
if postBody != nil {

docs/PdfApi.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Method | HTTP request | Description
212212
[**PostDocumentImageStamps**](PdfApi.md#PostDocumentImageStamps) | **Post** /pdf/{name}/stamps/image | Add document pages image stamps.
213213
[**PostDocumentImageStampsPageSpecified**](PdfApi.md#PostDocumentImageStampsPageSpecified) | **Post** /pdf/{name}/stamps/image/pagespecified | Add document image stamps to specified pages.
214214
[**PostDocumentPageNumberStamps**](PdfApi.md#PostDocumentPageNumberStamps) | **Post** /pdf/{name}/stamps/pagenumber | Add document page number stamps.
215+
[**PostDocumentPagesRotate**](PdfApi.md#PostDocumentPagesRotate) | **Post** /pdf/{name}/rotate | Rotate PDF document.
215216
[**PostDocumentTextFooter**](PdfApi.md#PostDocumentTextFooter) | **Post** /pdf/{name}/footer/text | Add document text footer.
216217
[**PostDocumentTextHeader**](PdfApi.md#PostDocumentTextHeader) | **Post** /pdf/{name}/header/text | Add document text header.
217218
[**PostDocumentTextReplace**](PdfApi.md#PostDocumentTextReplace) | **Post** /pdf/{name}/text/replace | Document's replace text method.
@@ -7253,6 +7254,42 @@ Name | Type | Description | Notes
72537254

72547255
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
72557256

7257+
# **PostDocumentPagesRotate**
7258+
> AsposeResponse PostDocumentPagesRotate(name, rotationAngle, pages, optional)
7259+
Rotate PDF document.
7260+
7261+
### Required Parameters
7262+
7263+
Name | Type | Description | Notes
7264+
------------- | ------------- | ------------- | -------------
7265+
**name** | **string**| The document name. |
7266+
**rotationAngle** | **string**| Rotation Angle (CKW). Can be 90, 180, 270. |
7267+
**pages** | **string**| Comma separated list of pages and page ranges. (Example: 1,3-5,8) |
7268+
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
7269+
7270+
### Optional Parameters
7271+
Optional parameters are passed through a map[string]interface{}.
7272+
7273+
Name | Type | Description | Notes
7274+
------------- | ------------- | ------------- | -------------
7275+
**name** | **string**| The document name. |
7276+
**rotationAngle** | **string**| Rotation Angle (CKW). Can be 90, 180, 270. |
7277+
**pages** | **string**| Comma separated list of pages and page ranges. (Example: 1,3-5,8) |
7278+
**storage** | **string**| The document storage. |
7279+
**folder** | **string**| The document folder. |
7280+
**password** | **string**| Base64 encoded password. |
7281+
7282+
### Return type
7283+
7284+
[**AsposeResponse**](AsposeResponse.md)
7285+
7286+
### HTTP request headers
7287+
7288+
- **Content-Type**: application/json
7289+
- **Accept**: application/json
7290+
7291+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
7292+
72567293
# **PostDocumentTextFooter**
72577294
> AsposeResponse PostDocumentTextFooter(name, textFooter, optional)
72587295
Add document text footer.

document_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,22 @@ func TestPostOrganizeDocuments(t *testing.T) {
304304
fmt.Printf("%d\tTestPostOrganizeDocuments - %db\n", GetBaseTest().GetTestNumber(), response.Code)
305305
}
306306
}
307+
308+
func TestPostDocumentPagesRotate(t *testing.T) {
309+
name := "4pages.pdf"
310+
if err := GetBaseTest().UploadFile(name); err != nil {
311+
t.Error(err)
312+
}
313+
args := map[string]interface{}{
314+
"folder": GetBaseTest().remoteFolder,
315+
}
316+
response, httpResponse, err := GetBaseTest().PdfAPI.PostDocumentPagesRotate(
317+
name, string(Rotationon90), "2-3", args)
318+
if err != nil {
319+
t.Error(err)
320+
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
321+
t.Fail()
322+
} else {
323+
fmt.Printf("%d\tPostDocumentPagesRotate - %db\n", GetBaseTest().GetTestNumber(), response.Code)
324+
}
325+
}

images_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,20 @@ func TestPutReplaceMultipleImage(t *testing.T) {
154154
"folder": GetBaseTest().remoteFolder,
155155
"imageFilePath": GetBaseTest().remoteFolder + "/" + imageFileName,
156156
}
157+
158+
responseImages1, _, err := GetBaseTest().PdfAPI.GetImages(name, 1, args)
159+
if err != nil {
160+
t.Error(err)
161+
}
162+
imageID1 := responseImages1.Images.List[0].Id
163+
responseImages2, _, err := GetBaseTest().PdfAPI.GetImages(name, 16, args)
164+
if err != nil {
165+
t.Error(err)
166+
}
167+
imageID2 := responseImages2.Images.List[0].Id
168+
157169
response, httpResponse, err := GetBaseTest().PdfAPI.PutReplaceMultipleImage(name,
158-
[]string{"GE5TENJVGQZTWMJYGQWDINRUFQ2DCMRMGY4TC", "GE5TIMJSGY3TWMJXG4WDIMBZFQ2DCOJMGQ3DK"}, args)
170+
[]string{imageID1, imageID2}, args)
159171
if err != nil {
160172
t.Error(err)
161173
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {

pdf_api.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17353,6 +17353,94 @@ func (a *PdfApiService) PostDocumentPageNumberStamps(name string, stamp PageNumb
1735317353
return successPayload, localVarHttpResponse, err
1735417354
}
1735517355

17356+
/* PdfApiService Rotate PDF document.
17357+
@param name The document name.
17358+
@param rotationAngle Rotation Angle (CKW). Can be 90, 180, 270.
17359+
@param pages Comma separated list of pages and page ranges. (Example: 1,3-5,8)
17360+
@param optional (nil or map[string]interface{}) with one or more of:
17361+
@param "storage" (string) The document storage.
17362+
@param "folder" (string) The document folder.
17363+
@param "password" (string) Base64 encoded password.
17364+
@return AsposeResponse*/
17365+
func (a *PdfApiService) PostDocumentPagesRotate(name string, rotationAngle string, pages string, localVarOptionals map[string]interface{}) (AsposeResponse, *http.Response, error) {
17366+
var (
17367+
localVarHttpMethod = strings.ToUpper("Post")
17368+
localVarPostBody interface{}
17369+
localVarFileName string
17370+
localVarFileBytes []byte
17371+
successPayload AsposeResponse
17372+
)
17373+
17374+
// create path and map variables
17375+
localVarPath := a.client.cfg.BasePath + "/pdf/{name}/rotate"
17376+
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", fmt.Sprintf("%v", name), -1)
17377+
17378+
localVarHeaderParams := make(map[string]string)
17379+
localVarQueryParams := _url.Values{}
17380+
localVarFormParams := _url.Values{}
17381+
17382+
if err := typeCheckParameter(localVarOptionals["storage"], "string", "storage"); err != nil {
17383+
return successPayload, nil, err
17384+
}
17385+
if err := typeCheckParameter(localVarOptionals["folder"], "string", "folder"); err != nil {
17386+
return successPayload, nil, err
17387+
}
17388+
if err := typeCheckParameter(localVarOptionals["password"], "string", "password"); err != nil {
17389+
return successPayload, nil, err
17390+
}
17391+
17392+
localVarQueryParams.Add("rotationAngle", parameterToString(rotationAngle, ""))
17393+
localVarQueryParams.Add("pages", parameterToString(pages, ""))
17394+
if localVarTempParam, localVarOk := localVarOptionals["storage"].(string); localVarOk {
17395+
localVarQueryParams.Add("storage", parameterToString(localVarTempParam, ""))
17396+
}
17397+
if localVarTempParam, localVarOk := localVarOptionals["folder"].(string); localVarOk {
17398+
localVarQueryParams.Add("folder", parameterToString(localVarTempParam, ""))
17399+
}
17400+
if localVarTempParam, localVarOk := localVarOptionals["password"].(string); localVarOk {
17401+
localVarQueryParams.Add("password", parameterToString(localVarTempParam, ""))
17402+
}
17403+
// to determine the Content-Type header
17404+
localVarHttpContentTypes := []string{ "application/json", }
17405+
17406+
// set Content-Type header
17407+
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
17408+
if localVarHttpContentType != "" {
17409+
localVarHeaderParams["Content-Type"] = localVarHttpContentType
17410+
}
17411+
17412+
// to determine the Accept header
17413+
localVarHttpHeaderAccepts := []string{
17414+
"application/json",
17415+
}
17416+
17417+
// set Accept header
17418+
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
17419+
if localVarHttpHeaderAccept != "" {
17420+
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
17421+
}
17422+
r, err := a.client.prepareRequest(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
17423+
if err != nil {
17424+
return successPayload, nil, err
17425+
}
17426+
17427+
localVarHttpResponse, err := a.client.callAPI(r)
17428+
if err != nil || localVarHttpResponse == nil {
17429+
return successPayload, localVarHttpResponse, err
17430+
}
17431+
defer localVarHttpResponse.Body.Close()
17432+
if localVarHttpResponse.StatusCode >= 300 {
17433+
bodyBytes, _ := io.ReadAll(localVarHttpResponse.Body)
17434+
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
17435+
}
17436+
17437+
if err = deserializeDTO(localVarHttpResponse.Body, &successPayload); err != nil {
17438+
return successPayload, localVarHttpResponse, err
17439+
}
17440+
17441+
return successPayload, localVarHttpResponse, err
17442+
}
17443+
1735617444
/* PdfApiService Add document text footer.
1735717445
@param name The document name.
1735817446
@param textFooter The text footer.

uses_cases/attachments/attachments_main.go renamed to uses_cases/attachments/attachments_helper.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,3 @@ func downloadFile(pdf_api *asposepdfcloud.PdfApiService, name string) {
6363
result_data, _, _ := pdf_api.DownloadFile(path.Join(REMOTE_FOLDER, name), args)
6464
saveByteArrayToFile(LOCAL_FOLDER, PDF_OUTPUT, result_data)
6565
}
66-
67-
func main() {
68-
pdfApi := initPdfApi()
69-
70-
uploadFile(pdfApi, PDF_DOCUMENT_WITH_ATTACH)
71-
getDocumentAttachments(pdfApi, PDF_DOCUMENT_WITH_ATTACH, REMOTE_FOLDER)
72-
getAttachmentByIndex(pdfApi, PDF_DOCUMENT_WITH_ATTACH, 1, REMOTE_FOLDER, LOCAL_FOLDER)
73-
74-
uploadFile(pdfApi, PDF_DOCUMENT)
75-
uploadFile(pdfApi, NEW_ATTACHMENT_FILE)
76-
appendAttachment(pdfApi, PDF_DOCUMENT, NEW_ATTACHMENT_FILE, NEW_ATTACHMENT_DECRIPTION, NEW_ATTACHMENT_MIME, REMOTE_FOLDER)
77-
78-
downloadFile(pdfApi, PDF_DOCUMENT)
79-
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package main
2+
3+
func main() {
4+
pdfApi := initPdfApi()
5+
6+
getDocumentAttachments(pdfApi, PDF_DOCUMENT_WITH_ATTACH, REMOTE_FOLDER)
7+
getAttachmentByIndex(pdfApi, PDF_DOCUMENT_WITH_ATTACH, 1, REMOTE_FOLDER, LOCAL_FOLDER)
8+
9+
appendAttachment(pdfApi, PDF_DOCUMENT, NEW_ATTACHMENT_FILE, NEW_ATTACHMENT_DECRIPTION, NEW_ATTACHMENT_MIME, REMOTE_FOLDER)
10+
}

uses_cases/bookmarks/append_bookmark.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
)
88

99
func appendBookmark(pdf_api *asposepdfcloud.PdfApiService, document_name string, bookmark_path string, title string, remote_folder string) {
10+
uploadFile(pdf_api, document_name)
11+
1012
args := map[string]interface{}{
1113
"folder": remote_folder,
1214
}
@@ -26,12 +28,12 @@ func appendBookmark(pdf_api *asposepdfcloud.PdfApiService, document_name string,
2628
Color: &asposepdfcloud.Color{A: 0x00, R: 0x00, G: 0xFF, B: 0x00},
2729
}
2830

29-
result, httpResponse, err := pdf_api.PostBookmark(document_name, bookmark_path, []asposepdfcloud.Bookmark{bookmark}, args)
31+
_, httpResponse, err := pdf_api.PostBookmark(document_name, bookmark_path, []asposepdfcloud.Bookmark{bookmark}, args)
3032
if err != nil {
3133
fmt.Println(err.Error())
3234
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
3335
fmt.Println("Unexpected error!")
3436
} else {
35-
fmt.Println(result.Bookmarks)
37+
downloadFile(pdf_api, document_name, "appended_attachment_")
3638
}
3739
}
Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"os"
56
"path"
67
"path/filepath"
@@ -18,8 +19,10 @@ const (
1819
)
1920

2021
func initPdfApi() *asposepdfcloud.PdfApiService {
21-
AppSID := "*************"
22-
AppKey := "*************"
22+
// Initialize Credentials and create Pdf.Cloud service object
23+
AppSID := "******" // Your Application SID
24+
AppKey := "******" // Your Application Key
25+
2326
pdfApi := asposepdfcloud.NewPdfApiService(AppSID, AppKey, "")
2427
return pdfApi
2528
}
@@ -31,23 +34,13 @@ func uploadFile(pdf_api *asposepdfcloud.PdfApiService, name string) {
3134
file, _ := os.Open(filepath.Join(LOCAL_FOLDER, name))
3235
_, _, _ = pdf_api.UploadFile(filepath.Join(REMOTE_FOLDER, name), file, args)
3336
}
34-
func downloadFile(pdf_api *asposepdfcloud.PdfApiService, name string) {
37+
func downloadFile(pdf_api *asposepdfcloud.PdfApiService, name string, output_prefix string) {
3538
args := map[string]interface{}{
3639
"folder": REMOTE_FOLDER,
3740
}
3841
result_data, _, _ := pdf_api.DownloadFile(path.Join(REMOTE_FOLDER, name), args)
39-
fileName := path.Join(LOCAL_FOLDER, PDF_OUTPUT)
42+
fileName := path.Join(LOCAL_FOLDER, output_prefix+PDF_OUTPUT)
4043
f, _ := os.Create(fileName)
4144
_, _ = f.Write(result_data)
42-
}
43-
44-
func main() {
45-
pdfApi := initPdfApi()
46-
uploadFile(pdfApi, PDF_DOCUMENT)
47-
extractDocumentBookmarks(pdfApi, PDF_DOCUMENT, REMOTE_FOLDER)
48-
extractBookmark(pdfApi, PDF_DOCUMENT, BOOKMARK_PATH, REMOTE_FOLDER)
49-
appendBookmark(pdfApi, PDF_DOCUMENT, BOOKMARK_PATH, BOOKMARK_TITLE, REMOTE_FOLDER)
50-
replaceBookmark(pdfApi, PDF_DOCUMENT, BOOKMARK_PATH, BOOKMARK_TITLE, REMOTE_FOLDER)
51-
removeBookmark(pdfApi, PDF_DOCUMENT, BOOKMARK_PATH, REMOTE_FOLDER)
52-
downloadFile(pdfApi, PDF_DOCUMENT)
45+
fmt.Println("Result file'" + fileName + "' successfully downloaded!")
5346
}

0 commit comments

Comments
 (0)