@@ -83,6 +83,118 @@ def from_config(cls, configuration):
8383 """
8484 return ViewApi (configuration )
8585
86+ def convert_and_download (self , request ,** kwargs ): # noqa: E501
87+ """Converts input document file to format specified # noqa: E501
88+
89+ This method makes a synchronous HTTP request by default. To make an
90+ asynchronous HTTP request, please pass is_async=True
91+
92+ :param is_async bool
93+ :param str format: Requested conversion format: HTML, JPG, PNG or PDF (required)
94+ :param file file: Input file to convert (required)
95+ :param str pages: Pages range to render, like \" 1,2\" or \" 3-5,10\"
96+ :param str password: Input document password
97+ :return: file
98+ If the method is called asynchronously,
99+ returns the request thread.
100+ """
101+ kwargs ['_return_http_data_only' ] = True
102+
103+ if kwargs .get ('is_async' ):
104+ return self ._convert_and_download_with_http_info (request , ** kwargs ) # noqa: E501
105+
106+ (data ) = self ._convert_and_download_with_http_info (request , ** kwargs ) # noqa: E501
107+ return data
108+
109+ def _convert_and_download_with_http_info (self , request , ** kwargs ): # noqa: E501
110+ """Converts input document file to format specified # noqa: E501
111+
112+ This method makes a synchronous HTTP request by default. To make an
113+ asynchronous HTTP request, please pass is_async=True
114+
115+ :param is_async bool
116+ :param ConvertAndDownloadRequest request object with parameters
117+ :return: file
118+ If the method is called asynchronously,
119+ returns the request thread.
120+ """
121+ params = locals ()
122+ params ['is_async' ] = ''
123+ params ['_return_http_data_only' ] = False
124+ params ['_preload_content' ] = True
125+ params ['_request_timeout' ] = ''
126+ for key , val in six .iteritems (params ['kwargs' ]):
127+ if key not in params :
128+ raise TypeError (
129+ "Got an unexpected keyword argument '%s'"
130+ " to method convert_and_download" % key
131+ )
132+ params [key ] = val
133+ del params ['kwargs' ]
134+ # verify the required parameter 'format' is set
135+ if request .format is None :
136+ raise ValueError ("Missing the required parameter `format` when calling `convert_and_download`" ) # noqa: E501
137+ # verify the required parameter 'file' is set
138+ if request .file is None :
139+ raise ValueError ("Missing the required parameter `file` when calling `convert_and_download`" ) # noqa: E501
140+
141+ collection_formats = {}
142+ path = '/viewer/convertAndDownload'
143+ path_params = {}
144+
145+ query_params = []
146+ if self .__downcase_first_letter ('format' ) in path :
147+ path = path .replace ('{' + self .__downcase_first_letter ('format' + '}' ), request .format if request .format is not None else '' )
148+ else :
149+ if request .format is not None :
150+ query_params .append ((self .__downcase_first_letter ('format' ), request .format )) # noqa: E501
151+ if self .__downcase_first_letter ('pages' ) in path :
152+ path = path .replace ('{' + self .__downcase_first_letter ('pages' + '}' ), request .pages if request .pages is not None else '' )
153+ else :
154+ if request .pages is not None :
155+ query_params .append ((self .__downcase_first_letter ('pages' ), request .pages )) # noqa: E501
156+ if self .__downcase_first_letter ('password' ) in path :
157+ path = path .replace ('{' + self .__downcase_first_letter ('password' + '}' ), request .password if request .password is not None else '' )
158+ else :
159+ if request .password is not None :
160+ query_params .append ((self .__downcase_first_letter ('password' ), request .password )) # noqa: E501
161+
162+ header_params = {}
163+
164+ form_params = []
165+ local_var_files = []
166+ if request .file is not None :
167+ local_var_files .append ((self .__downcase_first_letter ('File' ), request .file )) # noqa: E501
168+
169+ body_params = None
170+ # HTTP header `Accept`
171+ header_params ['Accept' ] = self .api_client .select_header_accept (
172+ ['application/json' ]) # noqa: E501
173+
174+ # HTTP header `Content-Type`
175+ header_params ['Content-Type' ] = self .api_client .select_header_content_type ( # noqa: E501
176+ ['multipart/form-data' ]) # noqa: E501
177+
178+ call_kwargs = {
179+ 'resource_path' :path ,
180+ 'method' :'PUT' ,
181+ 'path_params' :path_params ,
182+ 'query_params' :query_params ,
183+ 'header_params' :header_params ,
184+ 'body' :body_params ,
185+ 'post_params' :form_params ,
186+ 'files' :local_var_files ,
187+ 'response_type' :'file' , # noqa: E501
188+ 'auth_settings' :self .auth .get_auth_settings (),
189+ 'is_async' :params .get ('is_async' ),
190+ '_return_http_data_only' :params .get ('_return_http_data_only' ),
191+ '_preload_content' :params .get ('_preload_content' , True ),
192+ '_request_timeout' :params .get ('_request_timeout' ),
193+ 'collection_formats' :collection_formats
194+ }
195+
196+ return self .api_client .call_api (** call_kwargs ) # noqa: E501
197+
86198 def create_view (self , request ,** kwargs ): # noqa: E501
87199 """Render document pages # noqa: E501
88200
@@ -273,6 +385,48 @@ def __downcase_first_letter(self, s):
273385
274386# coding: utf-8
275387
388+ # --------------------------------------------------------------------------------
389+ # <copyright company="Aspose Pty Ltd" file="convert_and_download_request.py">
390+ # Copyright (c) 2003-2024 Aspose Pty Ltd
391+ # </copyright>
392+ # <summary>
393+ # Permission is hereby granted, free of charge, to any person obtaining a copy
394+ # of this software and associated documentation files (the "Software"), to deal
395+ # in the Software without restriction, including without limitation the rights
396+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
397+ # copies of the Software, and to permit persons to whom the Software is
398+ # furnished to do so, subject to the following conditions:
399+ #
400+ # The above copyright notice and this permission notice shall be included in all
401+ # copies or substantial portions of the Software.
402+ #
403+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
404+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
405+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
406+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
407+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
408+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
409+ # SOFTWARE.
410+ # </summary>
411+ # --------------------------------------------------------------------------------
412+
413+ class ConvertAndDownloadRequest (object ):
414+ """
415+ Request model for convert_and_download operation.
416+ :param format Requested conversion format: HTML, JPG, PNG or PDF
417+ :param file Input file to convert
418+ :param pages Pages range to render, like \" 1,2\" or \" 3-5,10\"
419+ :param password Input document password
420+ """
421+
422+ def __init__ (self , format , file , pages = None , password = None ):
423+ """Initializes new instance of ConvertAndDownloadRequest.""" # noqa: E501
424+ self .format = format
425+ self .file = file
426+ self .pages = pages
427+ self .password = password
428+ # coding: utf-8
429+
276430# --------------------------------------------------------------------------------
277431# <copyright company="Aspose Pty Ltd" file="create_view_request.py">
278432# Copyright (c) 2003-2024 Aspose Pty Ltd
0 commit comments