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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ 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.4
- Convert PDF to optimized Text.
- Convert PDF to EXCEL without Cloud Storage.
## Enhancements in Version 24.5
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.

## Bugs fixed in Version 24.5
- Aspose.PDF Cloud Service Throws Bad Gateway Error intermittently.

## Requirements.
Python 2.7 and 3.4+

Expand Down
2 changes: 1 addition & 1 deletion 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.4.0'
self.default_headers['x-aspose-client-version'] = '24.5.0'

self.self_host = self_host
self.app_key = app_key
Expand Down
129 changes: 129 additions & 0 deletions asposepdfcloud/apis/pdf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24553,6 +24553,135 @@ def post_flatten_document_with_http_info(self, name, **kwargs):
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)

def post_html_to_pdf(self, **kwargs):
"""
Convert HTML file (zip archive in request content) to PDF format and return resulting file in response.
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_html_to_pdf(callback=callback_function)

:param callback function: The callback function
for asynchronous request. (optional)
:param str html_file_name: Name of HTML file in ZIP.
:param float height: Page height
:param float width: Page width
:param bool is_landscape: Is page landscaped
:param float margin_left: Page margin left
:param float margin_bottom: Page margin bottom
:param float margin_right: Page margin right
:param float margin_top: Page margin top
:return: file
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('callback'):
return self.post_html_to_pdf_with_http_info(**kwargs)
else:
(data) = self.post_html_to_pdf_with_http_info(**kwargs)
return data

def post_html_to_pdf_with_http_info(self, **kwargs):
"""
Convert HTML file (zip archive in request content) to PDF format and return resulting file in response.
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_html_to_pdf_with_http_info(callback=callback_function)

:param callback function: The callback function
for asynchronous request. (optional)
:param str html_file_name: Name of HTML file in ZIP.
:param float height: Page height
:param float width: Page width
:param bool is_landscape: Is page landscaped
:param float margin_left: Page margin left
:param float margin_bottom: Page margin bottom
:param float margin_right: Page margin right
:param float margin_top: Page margin top
:return: file
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['html_file_name', 'height', 'width', 'is_landscape', 'margin_left', 'margin_bottom', 'margin_right', 'margin_top']
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_html_to_pdf" % key
)
params[key] = val
del params['kwargs']


collection_formats = {}

path_params = {}

query_params = []
if 'html_file_name' in params:
query_params.append(('htmlFileName', params['html_file_name']))
if 'height' in params:
query_params.append(('height', params['height']))
if 'width' in params:
query_params.append(('width', params['width']))
if 'is_landscape' in params:
query_params.append(('isLandscape', params['is_landscape']))
if 'margin_left' in params:
query_params.append(('marginLeft', params['margin_left']))
if 'margin_bottom' in params:
query_params.append(('marginBottom', params['margin_bottom']))
if 'margin_right' in params:
query_params.append(('marginRight', params['margin_right']))
if 'margin_top' in params:
query_params.append(('marginTop', params['margin_top']))

header_params = {}

form_params = []
local_var_files = {}

body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['multipart/form-data'])

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

# Authentication setting
auth_settings = ['JWT']

return self.api_client.call_api('/pdf/create/html', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='file',
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_import_fields_from_fdf(self, name, **kwargs):
"""
Update fields from FDF file in request.
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.4.0".\
"SDK Package Version: 24.5.0".\
format(env=sys.platform, pyversion=sys.version)
30 changes: 30 additions & 0 deletions docs/PdfApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Method | HTTP request | Description
[**post_document_text_replace**](PdfApi.md#post_document_text_replace) | **POST** /pdf/\{name}/text/replace | Document's replace text method.
[**post_encrypt_document_in_storage**](PdfApi.md#post_encrypt_document_in_storage) | **POST** /pdf/\{name}/encrypt | Encrypt document in storage.
[**post_flatten_document**](PdfApi.md#post_flatten_document) | **POST** /pdf/\{name}/flatten | Flatten the document.
[**post_html_to_pdf**](PdfApi.md#post_html_to_pdf) | **POST** /pdf/create/html | Convert HTML file (zip archive in request content) to PDF format and return resulting file in response.
[**post_import_fields_from_fdf**](PdfApi.md#post_import_fields_from_fdf) | **POST** /pdf/\{name}/import/fdf | Update fields from FDF file in request.
[**post_import_fields_from_xfdf**](PdfApi.md#post_import_fields_from_xfdf) | **POST** /pdf/\{name}/import/xfdf | Update fields from XFDF file in request.
[**post_import_fields_from_xml**](PdfApi.md#post_import_fields_from_xml) | **POST** /pdf/\{name}/import/xml | Update fields from XML file in request.
Expand Down Expand Up @@ -5571,6 +5572,35 @@ Name | Type | Description | Notes

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

# **post_html_to_pdf**
> file post_html_to_pdf(html_file_name=html_file_name, height=height, width=width, is_landscape=is_landscape, margin_left=margin_left, margin_bottom=margin_bottom, margin_right=margin_right, margin_top=margin_top)

Convert HTML file (zip archive in request content) to PDF format and return resulting file in response.

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**html_file_name** | **str**| Name of HTML file in ZIP. | [optional]
**height** | **float**| Page height | [optional]
**width** | **float**| Page width | [optional]
**is_landscape** | **bool**| Is page landscaped | [optional]
**margin_left** | **float**| Page margin left | [optional]
**margin_bottom** | **float**| Page margin bottom | [optional]
**margin_right** | **float**| Page margin right | [optional]
**margin_top** | **float**| Page margin top | [optional]

### Return type

**file**

### HTTP request headers

- **Content-Type**: multipart/form-data
- **Accept**: multipart/form-data

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

# **post_import_fields_from_fdf**
> AsposeResponse post_import_fields_from_fdf(name, storage=storage, folder=folder, fdf_data=fdf_data)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from setuptools import setup, find_packages

NAME = "asposepdfcloud"
VERSION = "24.4.0"
VERSION = "24.5.0"
# To install the library, run the following
#
# python setup.py install
Expand Down
4 changes: 2 additions & 2 deletions test/pdf_tests.py → test/pdf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


from __future__ import absolute_import
from asposepdfcloud.models import text_style
# from asposepdfcloud.models import text_style

import os
import sys
Expand All @@ -39,7 +39,7 @@

import asposepdfcloud
from asposepdfcloud.apis.pdf_api import PdfApi
from asposepdfcloud.rest import ApiException
# from asposepdfcloud.rest import ApiException
#from asposepdfcloud.models.annotations_ import AnnotationInfoResponse


Expand Down