'Base64 Docx to Base64 pdf
Im trying to convert a Base64 Docx to a Base64 pdf, for test purpose im receiving the base64 docx and im saving it in my Django static folder like this:
Proyect
--App
----static
------Docs
--------test.docx
So, Im trying with doxc2pdf library to make the convertion and the into base64 like this:
class Converttest(View):
def post(self, request, *args, **kwargs):
template = loader.get_template('home.html')
testdoc = static('Docs/test.docx')
pdf = convert(testdoc)
encoded = base64.b64encode(pdf)
context = {}
return HttpResponse(template.render(context, request))
But im getting this error:
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
> g:\python_projects\reps\stratos\strategy\views.py(162)post()
-> convert(testdoc)
Any idea what am I doing wrong ?
Solution 1:[1]
sample_string = "test string"
sample_string_bytes = sample_string.encode("ascii")
base64_bytes = base64.b64encode(sample_string_bytes)
base64_string = base64_bytes.decode("ascii")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | saro |
