How to decode this PDF format?

Viewed 22

i currently generate a PDF on my backend which look a bit like this :

PDF "Content"

When i try to download it on my frontEnd as .txt i get the result in the screenshot above but when i try to download it as PDF i get a blank file.

Here is my frontEnd code :

  const options = {
    endpoint,
    payload,
  };
  const { endpoint, payload } = options;
  const response = await axios.post(endpoint, { ...payload }, { responseType: 'blob' });
  const url = window.URL.createObjectURL(new Blob([response.data]), { type: 'application/pdf' });
  const link = document.createElement('a');
  link.href = url;
  link.setAttribute('download', 'file.pdf');
  document.body.appendChild(link);
  link.click();
0 Answers
Related