I am connecting to an API in which you return a PDF in bytes format and I want to know if there is any simple way to format it in PDF to be able to download it.
My problem is that it returns a string of data in this format:
b'%PDF-1.7 \n%\xe2\xe3\xcf\xd3 \n1 0 obj \n<< \n/Type /Catalog \n/Pages 2 0 R \n/PageMode /UseNone \n/ViewerPreferences << \n/FitWindow true \n/PageLayout /SinglePage \n/NonFullScreenPageMode /UseNone \n>> \n>> \nendobj \n5 0 obj \n<< \n/Length 6427 \n/Filter [ /FlateDecode ] \n>> ... '
What I discovered that is a PDF file in bytes.
I try to save it in a file and store it on my computer but it does not return anything and it does not save anything.
arraybytes = bytearray(sticker.bytesReport)
fichero = open("prueba.txt", "wb")
pdf.write(fichero)
pdf.close()