forked from ConvertAPI/convertapi-library-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_stream.py
More file actions
20 lines (12 loc) · 470 Bytes
/
convert_stream.py
File metadata and controls
20 lines (12 loc) · 470 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import convertapi
import os
import io
import tempfile
convertapi.api_secret = os.environ['CONVERT_API_SECRET'] # your api secret
# Example of using content stream to convert to pdf
# https://www.convertapi.com/txt-to-pdf
content = "Test content string"
upload_io = convertapi.UploadIO(content, 'test.txt')
result = convertapi.convert('pdf', { 'File': upload_io })
saved_files = result.save_files(tempfile.gettempdir())
print("The PDF saved to %s" % saved_files)