I made the same requests for converting DOCX, excel.ppt to PDF they worked. But Merge PDF does not work. I select PDF's with file picker than I send request to convertApi . But ConvertApi returns my original pdf not merged pdf.
var url = Uri.parse(
'https://v2.convertapi.com/convert/pdf/to/merge?Secret=XXXX');
int len = widget.docs.length;
var request = MultipartRequest("POST", url);
for (int i = 0; i < len; i++) {
final element = widget.docs[i];
request.files.add(
await MultipartFile.fromPath(
"Files",
element.path,
filename: element.name,
),
);
}
var response = await Response.fromStream(await request.send());
var decoded =
base64.decode(await jsonDecode(response.body)["Files"][0]["FileData"]);
This is a CURL example, the Files parameter must have an index like this: files[0]
, files[1]
. Please edit your Files
parameter name and add bracket and index for every passed new file.
curl -F "Files[0]=@/path/to/file1.pdf" -F "Files[1]=@/path/to/file2.pdf" https://v2.convertapi.com/convert/pdf/to/merge?Secret=<YOUR SECRET HERE>