Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ XLS, XLSX, PPTX, DOC, DOCX, MobiXML, JPEG, EMF, PNG, BMP, GIF, TIFF, Text
## Read PDF Formats
MHT, PCL, PS, XSLFO, MD

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

## Bugs fixed in Version 24.7
- PutPsInStorageToPdf throws: Cannot find resource ‘Aspose.PDF.dependencies.ZapfDingbats.ttf.
- Ocr method is not working.

## Requirements.
Python 2.7 and 3.4+

Expand Down
35 changes: 28 additions & 7 deletions asposepdfcloud/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, app_key, app_sid, host=None, self_host=False):
self.rest_client = RESTClientObject()
self.default_headers = {}
self.default_headers['x-aspose-client'] = 'python sdk'
self.default_headers['x-aspose-client-version'] = '24.7.0'
self.default_headers['x-aspose-client-version'] = '24.8.0'

self.self_host = self_host
self.app_key = app_key
Expand Down Expand Up @@ -250,14 +250,35 @@ def __request_token(self):
tokenUrl = self.host.replace("/v3.0", "") + resource_path
print("tokenUrl: " + tokenUrl)

# perform request and return response
response_data = self.request(method, tokenUrl,
headers=header_params,
post_params=post_params)
try:
# perform request and return response
response_data = self.request(method, tokenUrl,
headers=header_params,
post_params=post_params)
if isinstance(response_data.data, bytes):
responseJson = str(response_data.data, 'UTF-8')
else:
responseJson = str(response_data.data)
except Exception as ex:
if (hasattr(ex, 'body')):
if isinstance(ex.body, bytes):
responseJson = str(ex.body, 'UTF-8')
else:
responseJson = str(response_data.data)
else:
raise ApiException(ex)

data = json.loads(str(response_data.data))
config.access_token = data['access_token']
try:
data = json.loads(responseJson)
except json.JSONDecodeError as ex:
if responseJson.strip():
raise ApiException(reason=responseJson)
else:
raise ApiException(reason="empty token ({0})".format(responseJson))

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

def __add_o_auth_token(self, header_params):
config = Configuration()
Expand Down
246 changes: 246 additions & 0 deletions asposepdfcloud/apis/pdf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23783,6 +23783,129 @@ def post_document_image_header_with_http_info(self, name, image_header, **kwargs
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def post_document_image_stamps(self, name, stamps, **kwargs):
"""
Add document pages image stamps.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.post_document_image_stamps(name, stamps, callback=callback_function)

:param callback function: The callback function
for asynchronous request. (optional)
:param str name: The document name. (required)
:param list[ImageStamp] stamps: The array of stamp. (required)
:param str storage: The document storage.
:param str folder: The document folder.
:param str password: Base64 encoded password.
:return: AsposeResponse
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('callback'):
return self.post_document_image_stamps_with_http_info(name, stamps, **kwargs)
else:
(data) = self.post_document_image_stamps_with_http_info(name, stamps, **kwargs)
return data

def post_document_image_stamps_with_http_info(self, name, stamps, **kwargs):
"""
Add document pages image stamps.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.post_document_image_stamps_with_http_info(name, stamps, callback=callback_function)

:param callback function: The callback function
for asynchronous request. (optional)
:param str name: The document name. (required)
:param list[ImageStamp] stamps: The array of stamp. (required)
:param str storage: The document storage.
:param str folder: The document folder.
:param str password: Base64 encoded password.
:return: AsposeResponse
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['name', 'stamps', 'storage', 'folder', 'password']
all_params.append('callback')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')

params = locals()
for key, val in iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method post_document_image_stamps" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'name' is set
if ('name' not in params) or (params['name'] is None):
raise ValueError("Missing the required parameter `name` when calling `post_document_image_stamps`")
# verify the required parameter 'stamps' is set
if ('stamps' not in params) or (params['stamps'] is None):
raise ValueError("Missing the required parameter `stamps` when calling `post_document_image_stamps`")


collection_formats = {}

path_params = {}
if 'name' in params:
path_params['name'] = params['name']

query_params = []
if 'storage' in params:
query_params.append(('storage', params['storage']))
if 'folder' in params:
query_params.append(('folder', params['folder']))
if 'password' in params:
query_params.append(('password', params['password']))

header_params = {}

form_params = []
local_var_files = {}

body_params = None
if 'stamps' in params:
body_params = params['stamps']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type(['application/json'])

# Authentication setting
auth_settings = ['JWT']

return self.api_client.call_api('/pdf/{name}/stamps/image', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='AsposeResponse',
auth_settings=auth_settings,
callback=params.get('callback'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def post_document_page_number_stamps(self, name, stamp, **kwargs):
"""
Add document page number stamps.
Expand Down Expand Up @@ -24287,6 +24410,129 @@ def post_document_text_replace_with_http_info(self, name, text_replace, **kwargs
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def post_document_text_stamps(self, name, stamps, **kwargs):
"""
Add document pages text stamps.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.post_document_text_stamps(name, stamps, callback=callback_function)

:param callback function: The callback function
for asynchronous request. (optional)
:param str name: The document name. (required)
:param list[TextStamp] stamps: The array of stamp. (required)
:param str storage: The document storage.
:param str folder: The document folder.
:param str password: Base64 encoded password.
:return: AsposeResponse
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('callback'):
return self.post_document_text_stamps_with_http_info(name, stamps, **kwargs)
else:
(data) = self.post_document_text_stamps_with_http_info(name, stamps, **kwargs)
return data

def post_document_text_stamps_with_http_info(self, name, stamps, **kwargs):
"""
Add document pages text stamps.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.post_document_text_stamps_with_http_info(name, stamps, callback=callback_function)

:param callback function: The callback function
for asynchronous request. (optional)
:param str name: The document name. (required)
:param list[TextStamp] stamps: The array of stamp. (required)
:param str storage: The document storage.
:param str folder: The document folder.
:param str password: Base64 encoded password.
:return: AsposeResponse
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['name', 'stamps', 'storage', 'folder', 'password']
all_params.append('callback')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')

params = locals()
for key, val in iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method post_document_text_stamps" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'name' is set
if ('name' not in params) or (params['name'] is None):
raise ValueError("Missing the required parameter `name` when calling `post_document_text_stamps`")
# verify the required parameter 'stamps' is set
if ('stamps' not in params) or (params['stamps'] is None):
raise ValueError("Missing the required parameter `stamps` when calling `post_document_text_stamps`")


collection_formats = {}

path_params = {}
if 'name' in params:
path_params['name'] = params['name']

query_params = []
if 'storage' in params:
query_params.append(('storage', params['storage']))
if 'folder' in params:
query_params.append(('folder', params['folder']))
if 'password' in params:
query_params.append(('password', params['password']))

header_params = {}

form_params = []
local_var_files = {}

body_params = None
if 'stamps' in params:
body_params = params['stamps']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json'])

# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type(['application/json'])

# Authentication setting
auth_settings = ['JWT']

return self.api_client.call_api('/pdf/{name}/stamps/text', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='AsposeResponse',
auth_settings=auth_settings,
callback=params.get('callback'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def post_encrypt_document_in_storage(self, name, user_password, owner_password, crypto_algorithm, **kwargs):
"""
Encrypt document in storage.
Expand Down
2 changes: 1 addition & 1 deletion asposepdfcloud/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,5 @@ def to_debug_report(self):
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: 3.0\n"\
"SDK Package Version: 24.7.0".\
"SDK Package Version: 24.8.0".\
format(env=sys.platform, pyversion=sys.version)
12 changes: 6 additions & 6 deletions asposepdfcloud/models/optimize_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def password(self, password):
def allow_reuse_page_content(self):
"""
Gets the allow_reuse_page_content of this OptimizeOptions.
If true page contents will be reused when document is optimized for equal pages.
If true page contents will be reused when document is optimized for equal pages. LinkDuplcateStreams option must be set to true.

:return: The allow_reuse_page_content of this OptimizeOptions.
:rtype: bool
Expand All @@ -168,7 +168,7 @@ def allow_reuse_page_content(self):
def allow_reuse_page_content(self, allow_reuse_page_content):
"""
Sets the allow_reuse_page_content of this OptimizeOptions.
If true page contents will be reused when document is optimized for equal pages.
If true page contents will be reused when document is optimized for equal pages. LinkDuplcateStreams option must be set to true.

:param allow_reuse_page_content: The allow_reuse_page_content of this OptimizeOptions.
:type: bool
Expand Down Expand Up @@ -295,7 +295,7 @@ def remove_unused_streams(self, remove_unused_streams):
def unembed_fonts(self):
"""
Gets the unembed_fonts of this OptimizeOptions.
Make fonts not embedded if set to true.
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.

:return: The unembed_fonts of this OptimizeOptions.
:rtype: bool
Expand All @@ -306,7 +306,7 @@ def unembed_fonts(self):
def unembed_fonts(self, unembed_fonts):
"""
Sets the unembed_fonts of this OptimizeOptions.
Make fonts not embedded if set to true.
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.

:param unembed_fonts: The unembed_fonts of this OptimizeOptions.
:type: bool
Expand Down Expand Up @@ -364,7 +364,7 @@ def max_resolution(self, max_resolution):
def subset_fonts(self):
"""
Gets the subset_fonts of this OptimizeOptions.
Fonts will be converted into subsets if set to true.
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.

:return: The subset_fonts of this OptimizeOptions.
:rtype: bool
Expand All @@ -375,7 +375,7 @@ def subset_fonts(self):
def subset_fonts(self, subset_fonts):
"""
Sets the subset_fonts of this OptimizeOptions.
Fonts will be converted into subsets if set to true.
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.

:param subset_fonts: The subset_fonts of this OptimizeOptions.
:type: bool
Expand Down
Loading