Skip to content

Commit 4cfc1c9

Browse files
authored
Merge pull request #59 from aspose-pdf-cloud/develop
update 24.8
2 parents 65a70a4 + a4383e4 commit 4cfc1c9

File tree

7 files changed

+344
-14
lines changed

7 files changed

+344
-14
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ 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 24.7
12+
## Enhancements in Version 24.8
13+
- Adding Text stamps to multiple pages.
14+
- Adding Image stamps to multiple pages.
1315
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
1416

15-
## Bugs fixed in Version 24.7
16-
- PutPsInStorageToPdf throws: Cannot find resource ‘Aspose.PDF.dependencies.ZapfDingbats.ttf.
17-
- Ocr method is not working.
18-
1917
## Installation
2018
```
2119
go get -u github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v24

api_client.go

Lines changed: 7 additions & 3 deletions
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"] = "24.7.0"
179+
headerParams["x-aspose-client-version"] = "24.8.0"
180180

181181
// Detect postBody type and post.
182182
if postBody != nil {
@@ -440,9 +440,13 @@ func (a *APIClient) RequestOauthToken() error {
440440
bodyBytes, _ := io.ReadAll(resp.Body)
441441
var tr TokenResp
442442
if err = json.NewDecoder(bytes.NewReader(bodyBytes)).Decode(&tr); err != nil {
443-
return fmt.Errorf("%s (wrapped error: %w)", bodyBytes, err)
443+
if len(bytes.Trim(bodyBytes, " ")) > 0 {
444+
return fmt.Errorf("%s (wrapped error: %w)", bodyBytes, err)
445+
} else {
446+
return fmt.Errorf("empty token (%s)", bodyBytes)
447+
}
444448
}
445-
if len(tr.AccessToken) == 0 {
449+
if len(strings.Trim(tr.AccessToken, " ")) == 0 {
446450
return fmt.Errorf("empty token (%s)", bodyBytes)
447451
}
448452
a.cfg.AccessToken = tr.AccessToken

docs/OptimizeOptions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ Represents Pdf optimize options.
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**Password** | **string** | Specifies document password (if any) encoded with base-64. | [optional] [default to null]
8-
**AllowReusePageContent** | **bool** | If true page contents will be reused when document is optimized for equal pages. | [optional] [default to null]
8+
**AllowReusePageContent** | **bool** | If true page contents will be reused when document is optimized for equal pages. LinkDuplcateStreams option must be set to true. | [optional] [default to null]
99
**CompressImages** | **bool** | If this flag is set to true images will be compressed in the document. Compression level is specified with ImageQuality property. | [optional] [default to null]
1010
**ImageQuality** | **int32** | Specifies level of image compression when CompressImages flag is used. | [optional] [default to null]
1111
**LinkDuplcateStreams** | **bool** | If this flag is set to true, Resource streams will be analyzed. If duplicate streams are found (i.e. if stream contents is equal), then thees streams will be stored as one object. This allows to decrease document size in some cases (for example, when same document was concatenated multiple times). | [optional] [default to null]
1212
**RemoveUnusedObjects** | **bool** | If this flag is set to true, all document objects will be checked and unused objects (i.e. objects which does not have any reference) are removed from document. | [optional] [default to null]
1313
**RemoveUnusedStreams** | **bool** | If this flag set to true, every resource is checked on it's usage. If resource is never used, then resources is removed. This may decrease document size for example when pages were extracted from document. | [optional] [default to null]
14-
**UnembedFonts** | **bool** | Make fonts not embedded if set to true. | [optional] [default to null]
14+
**UnembedFonts** | **bool** | Make fonts not embedded if set to true. Unembedding a font means removing the embedded byte stream data of the font included in a PDF document. | [optional] [default to null]
1515
**ResizeImages** | **bool** | If this flag set to true and CompressImages is true images will be resized if image resolution is greater then specified MaxResolution parameter. | [optional] [default to null]
1616
**MaxResolution** | **int32** | Specifies maximum resolution of images. If image has higher resolution it will be scaled. | [optional] [default to null]
17-
**SubsetFonts** | **bool** | Fonts will be converted into subsets if set to true. | [optional] [default to null]
17+
**SubsetFonts** | **bool** | Fonts will be converted into subsets if set to true. Only those characters that are actually used in the layout are stored in the PDF. | [optional] [default to null]
1818
**RemovePrivateInfo** | **bool** | Remove private information (page piece info). | [optional] [default to null]
1919
**ImageEncoding** | [***ImageEncoding**](ImageEncoding.md) | Image encode which will be used. | [optional] [default to null]
2020
**ImageCompressionVersion** | [***ImageCompressionVersion**](ImageCompressionVersion.md) | Version of compression algorithm. Possible values are: "Standard" - standard compression, "Fast" - fast (improved compression which is faster then standard but may be applicable not for all images), "Mixed" - mixed (standard compression is applied to images which can not be compressed by faster algorithm, this may give best compression but more slow then "Fast" algorithm. Version "Fast" is not applicable for resizing images (standard method will be used). Default is "Standard". | [optional] [default to null]

docs/PdfApi.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,12 @@ Method | HTTP request | Description
203203
[**PostDecryptDocumentInStorage**](PdfApi.md#PostDecryptDocumentInStorage) | **Post** /pdf/{name}/decrypt | Decrypt document in storage.
204204
[**PostDocumentImageFooter**](PdfApi.md#PostDocumentImageFooter) | **Post** /pdf/{name}/footer/image | Add document image footer.
205205
[**PostDocumentImageHeader**](PdfApi.md#PostDocumentImageHeader) | **Post** /pdf/{name}/header/image | Add document image header.
206+
[**PostDocumentImageStamps**](PdfApi.md#PostDocumentImageStamps) | **Post** /pdf/{name}/stamps/image | Add document pages image stamps.
206207
[**PostDocumentPageNumberStamps**](PdfApi.md#PostDocumentPageNumberStamps) | **Post** /pdf/{name}/stamps/pagenumber | Add document page number stamps.
207208
[**PostDocumentTextFooter**](PdfApi.md#PostDocumentTextFooter) | **Post** /pdf/{name}/footer/text | Add document text footer.
208209
[**PostDocumentTextHeader**](PdfApi.md#PostDocumentTextHeader) | **Post** /pdf/{name}/header/text | Add document text header.
209210
[**PostDocumentTextReplace**](PdfApi.md#PostDocumentTextReplace) | **Post** /pdf/{name}/text/replace | Document's replace text method.
211+
[**PostDocumentTextStamps**](PdfApi.md#PostDocumentTextStamps) | **Post** /pdf/{name}/stamps/text | Add document pages text stamps.
210212
[**PostEncryptDocumentInStorage**](PdfApi.md#PostEncryptDocumentInStorage) | **Post** /pdf/{name}/encrypt | Encrypt document in storage.
211213
[**PostFlattenDocument**](PdfApi.md#PostFlattenDocument) | **Post** /pdf/{name}/flatten | Flatten the document.
212214
[**PostHtmlToPdf**](PdfApi.md#PostHtmlToPdf) | **Post** /pdf/create/html | Convert HTML file (zip archive in request content) to PDF format and return resulting file in response.
@@ -6931,6 +6933,40 @@ Name | Type | Description | Notes
69316933

69326934
[[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)
69336935

6936+
# **PostDocumentImageStamps**
6937+
> AsposeResponse PostDocumentImageStamps(name, stamps, optional)
6938+
Add document pages image stamps.
6939+
6940+
### Required Parameters
6941+
6942+
Name | Type | Description | Notes
6943+
------------- | ------------- | ------------- | -------------
6944+
**name** | **string**| The document name. |
6945+
**stamps** | [**[]ImageStamp**](ImageStamp.md)| The array of stamp. |
6946+
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
6947+
6948+
### Optional Parameters
6949+
Optional parameters are passed through a map[string]interface{}.
6950+
6951+
Name | Type | Description | Notes
6952+
------------- | ------------- | ------------- | -------------
6953+
**name** | **string**| The document name. |
6954+
**stamps** | [**[]ImageStamp**](ImageStamp.md)| The array of stamp. |
6955+
**storage** | **string**| The document storage. |
6956+
**folder** | **string**| The document folder. |
6957+
**password** | **string**| Base64 encoded password. |
6958+
6959+
### Return type
6960+
6961+
[**AsposeResponse**](AsposeResponse.md)
6962+
6963+
### HTTP request headers
6964+
6965+
- **Content-Type**: application/json
6966+
- **Accept**: application/json
6967+
6968+
[[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)
6969+
69346970
# **PostDocumentPageNumberStamps**
69356971
> AsposeResponse PostDocumentPageNumberStamps(name, stamp, optional)
69366972
Add document page number stamps.
@@ -7070,6 +7106,40 @@ Name | Type | Description | Notes
70707106

70717107
[[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)
70727108

7109+
# **PostDocumentTextStamps**
7110+
> AsposeResponse PostDocumentTextStamps(name, stamps, optional)
7111+
Add document pages text stamps.
7112+
7113+
### Required Parameters
7114+
7115+
Name | Type | Description | Notes
7116+
------------- | ------------- | ------------- | -------------
7117+
**name** | **string**| The document name. |
7118+
**stamps** | [**[]TextStamp**](TextStamp.md)| The array of stamp. |
7119+
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
7120+
7121+
### Optional Parameters
7122+
Optional parameters are passed through a map[string]interface{}.
7123+
7124+
Name | Type | Description | Notes
7125+
------------- | ------------- | ------------- | -------------
7126+
**name** | **string**| The document name. |
7127+
**stamps** | [**[]TextStamp**](TextStamp.md)| The array of stamp. |
7128+
**storage** | **string**| The document storage. |
7129+
**folder** | **string**| The document folder. |
7130+
**password** | **string**| Base64 encoded password. |
7131+
7132+
### Return type
7133+
7134+
[**AsposeResponse**](AsposeResponse.md)
7135+
7136+
### HTTP request headers
7137+
7138+
- **Content-Type**: application/json
7139+
- **Accept**: application/json
7140+
7141+
[[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)
7142+
70737143
# **PostEncryptDocumentInStorage**
70747144
> AsposeResponse PostEncryptDocumentInStorage(name, userPassword, ownerPassword, cryptoAlgorithm, optional)
70757145
Encrypt document in storage.

optimize_options.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ package asposepdfcloud
2525
type OptimizeOptions struct {
2626
// Specifies document password (if any) encoded with base-64.
2727
Password string `json:"Password,omitempty"`
28-
// If true page contents will be reused when document is optimized for equal pages.
28+
// If true page contents will be reused when document is optimized for equal pages. LinkDuplcateStreams option must be set to true.
2929
AllowReusePageContent bool `json:"AllowReusePageContent,omitempty"`
3030
// If this flag is set to true images will be compressed in the document. Compression level is specified with ImageQuality property.
3131
CompressImages bool `json:"CompressImages,omitempty"`
@@ -37,13 +37,13 @@ type OptimizeOptions struct {
3737
RemoveUnusedObjects bool `json:"RemoveUnusedObjects,omitempty"`
3838
// If this flag set to true, every resource is checked on it's usage. If resource is never used, then resources is removed. This may decrease document size for example when pages were extracted from document.
3939
RemoveUnusedStreams bool `json:"RemoveUnusedStreams,omitempty"`
40-
// Make fonts not embedded if set to true.
40+
// Make fonts not embedded if set to true. Unembedding a font means removing the embedded byte stream data of the font included in a PDF document.
4141
UnembedFonts bool `json:"UnembedFonts,omitempty"`
4242
// If this flag set to true and CompressImages is true images will be resized if image resolution is greater then specified MaxResolution parameter.
4343
ResizeImages bool `json:"ResizeImages,omitempty"`
4444
// Specifies maximum resolution of images. If image has higher resolution it will be scaled.
4545
MaxResolution int32 `json:"MaxResolution,omitempty"`
46-
// Fonts will be converted into subsets if set to true.
46+
// Fonts will be converted into subsets if set to true. Only those characters that are actually used in the layout are stored in the PDF.
4747
SubsetFonts bool `json:"SubsetFonts,omitempty"`
4848
// Remove private information (page piece info).
4949
RemovePrivateInfo bool `json:"RemovePrivateInfo,omitempty"`

pdf_api.go

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16530,6 +16530,93 @@ func (a *PdfApiService) PostDocumentImageHeader(name string, imageHeader ImageHe
1653016530
return successPayload, localVarHttpResponse, err
1653116531
}
1653216532

16533+
/* PdfApiService Add document pages image stamps.
16534+
@param name The document name.
16535+
@param stamps The array of stamp.
16536+
@param optional (nil or map[string]interface{}) with one or more of:
16537+
@param "storage" (string) The document storage.
16538+
@param "folder" (string) The document folder.
16539+
@param "password" (string) Base64 encoded password.
16540+
@return AsposeResponse*/
16541+
func (a *PdfApiService) PostDocumentImageStamps(name string, stamps []ImageStamp, localVarOptionals map[string]interface{}) (AsposeResponse, *http.Response, error) {
16542+
var (
16543+
localVarHttpMethod = strings.ToUpper("Post")
16544+
localVarPostBody interface{}
16545+
localVarFileName string
16546+
localVarFileBytes []byte
16547+
successPayload AsposeResponse
16548+
)
16549+
16550+
// create path and map variables
16551+
localVarPath := a.client.cfg.BasePath + "/pdf/{name}/stamps/image"
16552+
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", fmt.Sprintf("%v", name), -1)
16553+
16554+
localVarHeaderParams := make(map[string]string)
16555+
localVarQueryParams := _url.Values{}
16556+
localVarFormParams := _url.Values{}
16557+
16558+
if err := typeCheckParameter(localVarOptionals["storage"], "string", "storage"); err != nil {
16559+
return successPayload, nil, err
16560+
}
16561+
if err := typeCheckParameter(localVarOptionals["folder"], "string", "folder"); err != nil {
16562+
return successPayload, nil, err
16563+
}
16564+
if err := typeCheckParameter(localVarOptionals["password"], "string", "password"); err != nil {
16565+
return successPayload, nil, err
16566+
}
16567+
16568+
if localVarTempParam, localVarOk := localVarOptionals["storage"].(string); localVarOk {
16569+
localVarQueryParams.Add("storage", parameterToString(localVarTempParam, ""))
16570+
}
16571+
if localVarTempParam, localVarOk := localVarOptionals["folder"].(string); localVarOk {
16572+
localVarQueryParams.Add("folder", parameterToString(localVarTempParam, ""))
16573+
}
16574+
if localVarTempParam, localVarOk := localVarOptionals["password"].(string); localVarOk {
16575+
localVarQueryParams.Add("password", parameterToString(localVarTempParam, ""))
16576+
}
16577+
// to determine the Content-Type header
16578+
localVarHttpContentTypes := []string{ "application/json", }
16579+
16580+
// set Content-Type header
16581+
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
16582+
if localVarHttpContentType != "" {
16583+
localVarHeaderParams["Content-Type"] = localVarHttpContentType
16584+
}
16585+
16586+
// to determine the Accept header
16587+
localVarHttpHeaderAccepts := []string{
16588+
"application/json",
16589+
}
16590+
16591+
// set Accept header
16592+
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
16593+
if localVarHttpHeaderAccept != "" {
16594+
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
16595+
}
16596+
// body params
16597+
localVarPostBody = &stamps
16598+
r, err := a.client.prepareRequest(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
16599+
if err != nil {
16600+
return successPayload, nil, err
16601+
}
16602+
16603+
localVarHttpResponse, err := a.client.callAPI(r)
16604+
if err != nil || localVarHttpResponse == nil {
16605+
return successPayload, localVarHttpResponse, err
16606+
}
16607+
defer localVarHttpResponse.Body.Close()
16608+
if localVarHttpResponse.StatusCode >= 300 {
16609+
bodyBytes, _ := io.ReadAll(localVarHttpResponse.Body)
16610+
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
16611+
}
16612+
16613+
if err = deserializeDTO(localVarHttpResponse.Body, &successPayload); err != nil {
16614+
return successPayload, localVarHttpResponse, err
16615+
}
16616+
16617+
return successPayload, localVarHttpResponse, err
16618+
}
16619+
1653316620
/* PdfApiService Add document page number stamps.
1653416621
@param name The document name.
1653516622
@param stamp The stamp.
@@ -16899,6 +16986,93 @@ func (a *PdfApiService) PostDocumentTextReplace(name string, textReplace TextRep
1689916986
return successPayload, localVarHttpResponse, err
1690016987
}
1690116988

16989+
/* PdfApiService Add document pages text stamps.
16990+
@param name The document name.
16991+
@param stamps The array of stamp.
16992+
@param optional (nil or map[string]interface{}) with one or more of:
16993+
@param "storage" (string) The document storage.
16994+
@param "folder" (string) The document folder.
16995+
@param "password" (string) Base64 encoded password.
16996+
@return AsposeResponse*/
16997+
func (a *PdfApiService) PostDocumentTextStamps(name string, stamps []TextStamp, localVarOptionals map[string]interface{}) (AsposeResponse, *http.Response, error) {
16998+
var (
16999+
localVarHttpMethod = strings.ToUpper("Post")
17000+
localVarPostBody interface{}
17001+
localVarFileName string
17002+
localVarFileBytes []byte
17003+
successPayload AsposeResponse
17004+
)
17005+
17006+
// create path and map variables
17007+
localVarPath := a.client.cfg.BasePath + "/pdf/{name}/stamps/text"
17008+
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", fmt.Sprintf("%v", name), -1)
17009+
17010+
localVarHeaderParams := make(map[string]string)
17011+
localVarQueryParams := _url.Values{}
17012+
localVarFormParams := _url.Values{}
17013+
17014+
if err := typeCheckParameter(localVarOptionals["storage"], "string", "storage"); err != nil {
17015+
return successPayload, nil, err
17016+
}
17017+
if err := typeCheckParameter(localVarOptionals["folder"], "string", "folder"); err != nil {
17018+
return successPayload, nil, err
17019+
}
17020+
if err := typeCheckParameter(localVarOptionals["password"], "string", "password"); err != nil {
17021+
return successPayload, nil, err
17022+
}
17023+
17024+
if localVarTempParam, localVarOk := localVarOptionals["storage"].(string); localVarOk {
17025+
localVarQueryParams.Add("storage", parameterToString(localVarTempParam, ""))
17026+
}
17027+
if localVarTempParam, localVarOk := localVarOptionals["folder"].(string); localVarOk {
17028+
localVarQueryParams.Add("folder", parameterToString(localVarTempParam, ""))
17029+
}
17030+
if localVarTempParam, localVarOk := localVarOptionals["password"].(string); localVarOk {
17031+
localVarQueryParams.Add("password", parameterToString(localVarTempParam, ""))
17032+
}
17033+
// to determine the Content-Type header
17034+
localVarHttpContentTypes := []string{ "application/json", }
17035+
17036+
// set Content-Type header
17037+
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
17038+
if localVarHttpContentType != "" {
17039+
localVarHeaderParams["Content-Type"] = localVarHttpContentType
17040+
}
17041+
17042+
// to determine the Accept header
17043+
localVarHttpHeaderAccepts := []string{
17044+
"application/json",
17045+
}
17046+
17047+
// set Accept header
17048+
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
17049+
if localVarHttpHeaderAccept != "" {
17050+
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
17051+
}
17052+
// body params
17053+
localVarPostBody = &stamps
17054+
r, err := a.client.prepareRequest(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
17055+
if err != nil {
17056+
return successPayload, nil, err
17057+
}
17058+
17059+
localVarHttpResponse, err := a.client.callAPI(r)
17060+
if err != nil || localVarHttpResponse == nil {
17061+
return successPayload, localVarHttpResponse, err
17062+
}
17063+
defer localVarHttpResponse.Body.Close()
17064+
if localVarHttpResponse.StatusCode >= 300 {
17065+
bodyBytes, _ := io.ReadAll(localVarHttpResponse.Body)
17066+
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
17067+
}
17068+
17069+
if err = deserializeDTO(localVarHttpResponse.Body, &successPayload); err != nil {
17070+
return successPayload, localVarHttpResponse, err
17071+
}
17072+
17073+
return successPayload, localVarHttpResponse, err
17074+
}
17075+
1690217076
/* PdfApiService Encrypt document in storage.
1690317077
@param name Document name.
1690417078
@param userPassword User password (encrypted Base64).

0 commit comments

Comments
 (0)