-1

I am working on a flutter project in which the API returns PDF. But it is in the form of text like this

%PDF-1.4 1 0 obj << /Title (��) /Creator(��) /Producer(��)

How can I save it as a .pdf.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Aakash
  • 33
  • 5
  • 4
    Those are the bytes in the pdf. Just save them. – Thorbjørn Ravn Andersen Jul 29 '21 at 16:42
  • Does this answer your question? [How to download a file using http.post with url encoded body in flutter?](https://stackoverflow.com/questions/62571306/how-to-download-a-file-using-http-post-with-url-encoded-body-in-flutter) – esqew Jul 29 '21 at 16:56

1 Answers1

0

API is basically returning you bytes. Just write those bytes directly to a file usinng java.nio.Files class or FileOutputStream as you like. Remember to not convert bytes to String as it may affect the encoding and charset, possibly corrupting your file

Aviral Ahuja
  • 205
  • 1
  • 2
  • 14