Merge Files
Two or more imported or converted image files (jpg, png, etc.) can be merged into a single PDF or GIF file. The task IDs must be provided as the input so that FreeConvert uses the correct files for the merge task.
For example, if you have several files and simply need to merge them into a single PDF or GIF, you only need to upload those files into FreeConvert and then initiate the merge task by including the import task IDs from the previous step.
FreeConvert also supports advanced options for merging files. Currently, only image and PDF files are supported for merging.
curl -X POST https://api.freeconvert.com/v1/process/merge \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access_token}'
# Body Parameter
{
"input": [
"task_id_1",
"task_id_2"
],
"output_format": "pdf",
"filename": "some.pdf", # optional
"options": {
# …advanced options…
},
}
POST https://api.freeconvert.com/v1/process/merge HTTP/1.1
Host: api.freeconvert.com
Content-Type: application/json
Accept: application/json
# Body Parameter
{
"input": [
"task_id_1",
"task_id_2"
],
"output_format": "pdf",
"filename": "some.pdf", // optional
"options": {
<!-- …advanced options… -->
},
}
inputBody = {
input: [task_id_1, task_id_2],
output_format: "pdf",
filename: "some.pdf", // optional
options: {
// …advanced options…
},
};
const headers = {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${access_token}`,
};
fetch("https://api.freeconvert.com/v1/process/merge", {
method: "POST",
body: inputBody,
headers: headers,
})
.then(function (res) {
return res.json();
})
.then(function (body) {
console.log(body);
});
import requests
request_body = {
'input': [task_id_1, task_id_2],
'output_format': 'pdf',
'filename': 'some.pdf', # optional
'options': {
# …advanced options…
}
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer' + access_token
}
result = requests.post(
'https://api.freeconvert.com/v1/process/merge',
data = request_body,
headers = headers
)
print(result.json())
require 'rest-client'
require 'json'
request_body = {
'input' => [task_id_1, task_id_2],
'output_format' => 'pdf',
'filename' => 'some.pdf', # optional
'options': {
# …advanced options…
}
}
headers = {
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer' + access_token
}
result = RestClient.post(
'https://api.freeconvert.com/v1/process/merge',
body: request_body,
headers: headers
)
JSON.parse(result)
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer ' $access_token,
);
$client = new \GuzzleHttp\Client();
$request_body = array(
'input' => array(task_id_1, task_id_2),
'output_format': 'pdf',
'filename': 'some.pdf', # optional
'options' => {
// …advanced options…
},
)
try {
$response = $client->request(
'POST',
'https://api.freeconvert.com/v1/process/merge',
array(
'headers' => $headers,
'content' => json_encode($request_body),
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("https://api.freeconvert.com/v1/process/merge");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream())
);
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
jsonReq := map[string][]string{
"input": []string{task_id_1, task_id_2},
"output_format": string{"pdf"},
"filename": string{"some.zip"}, // optional
"options": map[string[]]string{
// …advanced options…
}
}
headers := map[string][]string{
"Content-Type": string{"application/json"},
"Accept": string{"application/json"},
"Authorization": string{"Bearer" + access_token},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest(
"POST",
"https://api.freeconvert.com/v1/process/merge",
data
)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}