Community

How to use xml:writeFormatting within Python wrapper of your API?

I am using Python wrapper to your API published here https://github.com/abbyysdk/ocrsdk.com/tree/master/Python but I cannot put there this parameter xml:writeFormatting Can you advise me what to do?  
result = ocr_engine.process_and_download(file, exportFormat='xml', language='English', writeFormatting = 'true')
print(result["xml"].read())

Or

result = ocr_engine.process_and_download(file, exportFormat='xml', language='English', xmlwriteFormatting = 'true')
print(result["xml"].read())

Does not work… I do not know what is the name of the parameter… should it be really in URL like "http://cloud.ocrsdk.com/processImage?language=english&exportFormat=xml,xml:writeformatting=true

In that case I probably need to change the code provided by you because I guess I cannot pass xml:writeformatting via **kwargs

def process_and_download(self, file, timeout=300, **kwargs):
if 'exportFormat' in list(kwargs.keys()):
formats = kwargs['exportFormat']
else:
formats = DEFAULT_EXPORT_FORMAT
formats = formats.split(',')

task = self.processImage(file=file, **kwargs)
result = self.wait_for_task(task, timeout=timeout)

urls_keys = [key for key in list(result.keys()) if key.startswith('resultUrl')]
urls = list(zip(formats, list(map(result.__getitem__, urls_keys))))

streams = dict()
for format, url in urls:
result = self.session.get(url)
streams[format] = BytesIO(result.content)
return streams
0

Comments

1 comment

Please sign in to leave a comment.