Skip to content

Commit 3e5648a

Browse files
author
kirill.novinskiy
committed
update 24.8
1 parent ae17bdb commit 3e5648a

File tree

9 files changed

+395
-23
lines changed

9 files changed

+395
-23
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ XLS, XLSX, PPTX, DOC, DOCX, MobiXML, JPEG, EMF, PNG, BMP, GIF, TIFF, Text
3030
## Read PDF Formats
3131
MHT, PCL, PS, XSLFO, MD
3232

33-
## Enhancements in Version 24.7
33+
## Enhancements in Version 24.8
34+
- Adding Text stamps to multiple pages.
35+
- Adding Image stamps to multiple pages.
3436
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
3537

36-
## Bugs fixed in Version 24.7
37-
- PutPsInStorageToPdf throws: Cannot find resource ‘Aspose.PDF.dependencies.ZapfDingbats.ttf.
38-
- Ocr method is not working.
39-
4038
## Requirements.
4139
Python 2.7 and 3.4+
4240

asposepdfcloud/api_client.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(self, app_key, app_sid, host=None, self_host=False):
8383
self.rest_client = RESTClientObject()
8484
self.default_headers = {}
8585
self.default_headers['x-aspose-client'] = 'python sdk'
86-
self.default_headers['x-aspose-client-version'] = '24.7.0'
86+
self.default_headers['x-aspose-client-version'] = '24.8.0'
8787

8888
self.self_host = self_host
8989
self.app_key = app_key
@@ -250,14 +250,35 @@ def __request_token(self):
250250
tokenUrl = self.host.replace("/v3.0", "") + resource_path
251251
print("tokenUrl: " + tokenUrl)
252252

253-
# perform request and return response
254-
response_data = self.request(method, tokenUrl,
255-
headers=header_params,
256-
post_params=post_params)
253+
try:
254+
# perform request and return response
255+
response_data = self.request(method, tokenUrl,
256+
headers=header_params,
257+
post_params=post_params)
258+
if isinstance(response_data.data, bytes):
259+
responseJson = str(response_data.data, 'UTF-8')
260+
else:
261+
responseJson = str(response_data.data)
262+
except Exception as ex:
263+
if (hasattr(ex, 'body')):
264+
if isinstance(ex.body, bytes):
265+
responseJson = str(ex.body, 'UTF-8')
266+
else:
267+
responseJson = str(response_data.data)
268+
else:
269+
raise ApiException(ex)
257270

258-
data = json.loads(str(response_data.data))
259-
config.access_token = data['access_token']
271+
try:
272+
data = json.loads(responseJson)
273+
except json.JSONDecodeError as ex:
274+
if responseJson.strip():
275+
raise ApiException(reason=responseJson)
276+
else:
277+
raise ApiException(reason="empty token ({0})".format(responseJson))
260278

279+
if 'access_token' not in data or not data['access_token'] or data['access_token'].strip() == "":
280+
raise ApiException(reason="empty token ({0})".format(responseJson))
281+
config.access_token = data['access_token']
261282

262283
def __add_o_auth_token(self, header_params):
263284
config = Configuration()

asposepdfcloud/apis/pdf_api.py

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23783,6 +23783,129 @@ def post_document_image_header_with_http_info(self, name, image_header, **kwargs
2378323783
_request_timeout=params.get('_request_timeout'),
2378423784
collection_formats=collection_formats)
2378523785

23786+
def post_document_image_stamps(self, name, stamps, **kwargs):
23787+
"""
23788+
Add document pages image stamps.
23789+
This method makes a synchronous HTTP request by default. To make an
23790+
asynchronous HTTP request, please define a `callback` function
23791+
to be invoked when receiving the response.
23792+
>>> def callback_function(response):
23793+
>>> pprint(response)
23794+
>>>
23795+
>>> thread = api.post_document_image_stamps(name, stamps, callback=callback_function)
23796+
23797+
:param callback function: The callback function
23798+
for asynchronous request. (optional)
23799+
:param str name: The document name. (required)
23800+
:param list[ImageStamp] stamps: The array of stamp. (required)
23801+
:param str storage: The document storage.
23802+
:param str folder: The document folder.
23803+
:param str password: Base64 encoded password.
23804+
:return: AsposeResponse
23805+
If the method is called asynchronously,
23806+
returns the request thread.
23807+
"""
23808+
kwargs['_return_http_data_only'] = True
23809+
if kwargs.get('callback'):
23810+
return self.post_document_image_stamps_with_http_info(name, stamps, **kwargs)
23811+
else:
23812+
(data) = self.post_document_image_stamps_with_http_info(name, stamps, **kwargs)
23813+
return data
23814+
23815+
def post_document_image_stamps_with_http_info(self, name, stamps, **kwargs):
23816+
"""
23817+
Add document pages image stamps.
23818+
This method makes a synchronous HTTP request by default. To make an
23819+
asynchronous HTTP request, please define a `callback` function
23820+
to be invoked when receiving the response.
23821+
>>> def callback_function(response):
23822+
>>> pprint(response)
23823+
>>>
23824+
>>> thread = api.post_document_image_stamps_with_http_info(name, stamps, callback=callback_function)
23825+
23826+
:param callback function: The callback function
23827+
for asynchronous request. (optional)
23828+
:param str name: The document name. (required)
23829+
:param list[ImageStamp] stamps: The array of stamp. (required)
23830+
:param str storage: The document storage.
23831+
:param str folder: The document folder.
23832+
:param str password: Base64 encoded password.
23833+
:return: AsposeResponse
23834+
If the method is called asynchronously,
23835+
returns the request thread.
23836+
"""
23837+
23838+
all_params = ['name', 'stamps', 'storage', 'folder', 'password']
23839+
all_params.append('callback')
23840+
all_params.append('_return_http_data_only')
23841+
all_params.append('_preload_content')
23842+
all_params.append('_request_timeout')
23843+
23844+
params = locals()
23845+
for key, val in iteritems(params['kwargs']):
23846+
if key not in all_params:
23847+
raise TypeError(
23848+
"Got an unexpected keyword argument '%s'"
23849+
" to method post_document_image_stamps" % key
23850+
)
23851+
params[key] = val
23852+
del params['kwargs']
23853+
# verify the required parameter 'name' is set
23854+
if ('name' not in params) or (params['name'] is None):
23855+
raise ValueError("Missing the required parameter `name` when calling `post_document_image_stamps`")
23856+
# verify the required parameter 'stamps' is set
23857+
if ('stamps' not in params) or (params['stamps'] is None):
23858+
raise ValueError("Missing the required parameter `stamps` when calling `post_document_image_stamps`")
23859+
23860+
23861+
collection_formats = {}
23862+
23863+
path_params = {}
23864+
if 'name' in params:
23865+
path_params['name'] = params['name']
23866+
23867+
query_params = []
23868+
if 'storage' in params:
23869+
query_params.append(('storage', params['storage']))
23870+
if 'folder' in params:
23871+
query_params.append(('folder', params['folder']))
23872+
if 'password' in params:
23873+
query_params.append(('password', params['password']))
23874+
23875+
header_params = {}
23876+
23877+
form_params = []
23878+
local_var_files = {}
23879+
23880+
body_params = None
23881+
if 'stamps' in params:
23882+
body_params = params['stamps']
23883+
# HTTP header `Accept`
23884+
header_params['Accept'] = self.api_client.\
23885+
select_header_accept(['application/json'])
23886+
23887+
# HTTP header `Content-Type`
23888+
header_params['Content-Type'] = self.api_client.\
23889+
select_header_content_type(['application/json'])
23890+
23891+
# Authentication setting
23892+
auth_settings = ['JWT']
23893+
23894+
return self.api_client.call_api('/pdf/{name}/stamps/image', 'POST',
23895+
path_params,
23896+
query_params,
23897+
header_params,
23898+
body=body_params,
23899+
post_params=form_params,
23900+
files=local_var_files,
23901+
response_type='AsposeResponse',
23902+
auth_settings=auth_settings,
23903+
callback=params.get('callback'),
23904+
_return_http_data_only=params.get('_return_http_data_only'),
23905+
_preload_content=params.get('_preload_content', True),
23906+
_request_timeout=params.get('_request_timeout'),
23907+
collection_formats=collection_formats)
23908+
2378623909
def post_document_page_number_stamps(self, name, stamp, **kwargs):
2378723910
"""
2378823911
Add document page number stamps.
@@ -24287,6 +24410,129 @@ def post_document_text_replace_with_http_info(self, name, text_replace, **kwargs
2428724410
_request_timeout=params.get('_request_timeout'),
2428824411
collection_formats=collection_formats)
2428924412

24413+
def post_document_text_stamps(self, name, stamps, **kwargs):
24414+
"""
24415+
Add document pages text stamps.
24416+
This method makes a synchronous HTTP request by default. To make an
24417+
asynchronous HTTP request, please define a `callback` function
24418+
to be invoked when receiving the response.
24419+
>>> def callback_function(response):
24420+
>>> pprint(response)
24421+
>>>
24422+
>>> thread = api.post_document_text_stamps(name, stamps, callback=callback_function)
24423+
24424+
:param callback function: The callback function
24425+
for asynchronous request. (optional)
24426+
:param str name: The document name. (required)
24427+
:param list[TextStamp] stamps: The array of stamp. (required)
24428+
:param str storage: The document storage.
24429+
:param str folder: The document folder.
24430+
:param str password: Base64 encoded password.
24431+
:return: AsposeResponse
24432+
If the method is called asynchronously,
24433+
returns the request thread.
24434+
"""
24435+
kwargs['_return_http_data_only'] = True
24436+
if kwargs.get('callback'):
24437+
return self.post_document_text_stamps_with_http_info(name, stamps, **kwargs)
24438+
else:
24439+
(data) = self.post_document_text_stamps_with_http_info(name, stamps, **kwargs)
24440+
return data
24441+
24442+
def post_document_text_stamps_with_http_info(self, name, stamps, **kwargs):
24443+
"""
24444+
Add document pages text stamps.
24445+
This method makes a synchronous HTTP request by default. To make an
24446+
asynchronous HTTP request, please define a `callback` function
24447+
to be invoked when receiving the response.
24448+
>>> def callback_function(response):
24449+
>>> pprint(response)
24450+
>>>
24451+
>>> thread = api.post_document_text_stamps_with_http_info(name, stamps, callback=callback_function)
24452+
24453+
:param callback function: The callback function
24454+
for asynchronous request. (optional)
24455+
:param str name: The document name. (required)
24456+
:param list[TextStamp] stamps: The array of stamp. (required)
24457+
:param str storage: The document storage.
24458+
:param str folder: The document folder.
24459+
:param str password: Base64 encoded password.
24460+
:return: AsposeResponse
24461+
If the method is called asynchronously,
24462+
returns the request thread.
24463+
"""
24464+
24465+
all_params = ['name', 'stamps', 'storage', 'folder', 'password']
24466+
all_params.append('callback')
24467+
all_params.append('_return_http_data_only')
24468+
all_params.append('_preload_content')
24469+
all_params.append('_request_timeout')
24470+
24471+
params = locals()
24472+
for key, val in iteritems(params['kwargs']):
24473+
if key not in all_params:
24474+
raise TypeError(
24475+
"Got an unexpected keyword argument '%s'"
24476+
" to method post_document_text_stamps" % key
24477+
)
24478+
params[key] = val
24479+
del params['kwargs']
24480+
# verify the required parameter 'name' is set
24481+
if ('name' not in params) or (params['name'] is None):
24482+
raise ValueError("Missing the required parameter `name` when calling `post_document_text_stamps`")
24483+
# verify the required parameter 'stamps' is set
24484+
if ('stamps' not in params) or (params['stamps'] is None):
24485+
raise ValueError("Missing the required parameter `stamps` when calling `post_document_text_stamps`")
24486+
24487+
24488+
collection_formats = {}
24489+
24490+
path_params = {}
24491+
if 'name' in params:
24492+
path_params['name'] = params['name']
24493+
24494+
query_params = []
24495+
if 'storage' in params:
24496+
query_params.append(('storage', params['storage']))
24497+
if 'folder' in params:
24498+
query_params.append(('folder', params['folder']))
24499+
if 'password' in params:
24500+
query_params.append(('password', params['password']))
24501+
24502+
header_params = {}
24503+
24504+
form_params = []
24505+
local_var_files = {}
24506+
24507+
body_params = None
24508+
if 'stamps' in params:
24509+
body_params = params['stamps']
24510+
# HTTP header `Accept`
24511+
header_params['Accept'] = self.api_client.\
24512+
select_header_accept(['application/json'])
24513+
24514+
# HTTP header `Content-Type`
24515+
header_params['Content-Type'] = self.api_client.\
24516+
select_header_content_type(['application/json'])
24517+
24518+
# Authentication setting
24519+
auth_settings = ['JWT']
24520+
24521+
return self.api_client.call_api('/pdf/{name}/stamps/text', 'POST',
24522+
path_params,
24523+
query_params,
24524+
header_params,
24525+
body=body_params,
24526+
post_params=form_params,
24527+
files=local_var_files,
24528+
response_type='AsposeResponse',
24529+
auth_settings=auth_settings,
24530+
callback=params.get('callback'),
24531+
_return_http_data_only=params.get('_return_http_data_only'),
24532+
_preload_content=params.get('_preload_content', True),
24533+
_request_timeout=params.get('_request_timeout'),
24534+
collection_formats=collection_formats)
24535+
2429024536
def post_encrypt_document_in_storage(self, name, user_password, owner_password, crypto_algorithm, **kwargs):
2429124537
"""
2429224538
Encrypt document in storage.

asposepdfcloud/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,5 @@ def to_debug_report(self):
199199
"OS: {env}\n"\
200200
"Python Version: {pyversion}\n"\
201201
"Version of the API: 3.0\n"\
202-
"SDK Package Version: 24.7.0".\
202+
"SDK Package Version: 24.8.0".\
203203
format(env=sys.platform, pyversion=sys.version)

asposepdfcloud/models/optimize_options.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def password(self, password):
157157
def allow_reuse_page_content(self):
158158
"""
159159
Gets the allow_reuse_page_content of this OptimizeOptions.
160-
If true page contents will be reused when document is optimized for equal pages.
160+
If true page contents will be reused when document is optimized for equal pages. LinkDuplcateStreams option must be set to true.
161161
162162
:return: The allow_reuse_page_content of this OptimizeOptions.
163163
:rtype: bool
@@ -168,7 +168,7 @@ def allow_reuse_page_content(self):
168168
def allow_reuse_page_content(self, allow_reuse_page_content):
169169
"""
170170
Sets the allow_reuse_page_content of this OptimizeOptions.
171-
If true page contents will be reused when document is optimized for equal pages.
171+
If true page contents will be reused when document is optimized for equal pages. LinkDuplcateStreams option must be set to true.
172172
173173
:param allow_reuse_page_content: The allow_reuse_page_content of this OptimizeOptions.
174174
:type: bool
@@ -295,7 +295,7 @@ def remove_unused_streams(self, remove_unused_streams):
295295
def unembed_fonts(self):
296296
"""
297297
Gets the unembed_fonts of this OptimizeOptions.
298-
Make fonts not embedded if set to true.
298+
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.
299299
300300
:return: The unembed_fonts of this OptimizeOptions.
301301
:rtype: bool
@@ -306,7 +306,7 @@ def unembed_fonts(self):
306306
def unembed_fonts(self, unembed_fonts):
307307
"""
308308
Sets the unembed_fonts of this OptimizeOptions.
309-
Make fonts not embedded if set to true.
309+
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.
310310
311311
:param unembed_fonts: The unembed_fonts of this OptimizeOptions.
312312
:type: bool
@@ -364,7 +364,7 @@ def max_resolution(self, max_resolution):
364364
def subset_fonts(self):
365365
"""
366366
Gets the subset_fonts of this OptimizeOptions.
367-
Fonts will be converted into subsets if set to true.
367+
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.
368368
369369
:return: The subset_fonts of this OptimizeOptions.
370370
:rtype: bool
@@ -375,7 +375,7 @@ def subset_fonts(self):
375375
def subset_fonts(self, subset_fonts):
376376
"""
377377
Sets the subset_fonts of this OptimizeOptions.
378-
Fonts will be converted into subsets if set to true.
378+
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.
379379
380380
:param subset_fonts: The subset_fonts of this OptimizeOptions.
381381
:type: bool

0 commit comments

Comments
 (0)