I was trying to use convertApi (https://www.convertapi.com/pdf-to-compress) in Flutter to compress a pdf. I managed to send a request, get a 200 response code, and extract the 'FileData' from the Json response. However, when I convert the string obtained from the Json to a Uint8List then save the file, the pdf is unreadable...
When I make the request from the website with the same pdf, everything is working fine.
Does someone have a clue of what I am doing wrong ?
var request = new MultipartRequest("POST", url);
request.files.add(MultipartFile.fromBytes(
'File',
pdf.save(), // This is a List<int>
contentType: MediaType("application", "pdf"),
filename: '${FS.pdfStorage}/${task.header.taskId}.pdf'));
var response = await Response.fromStream(await request.send());
var compressedPdf = Uint8List.fromList(jsonDecode((response.body))["Files"][0]["FileData"].codeUnits);