I have searched around to convert an image to a PDF but was unable to find anything. I came across CloudConvert which has 25 free credits per day for file conversions.
A few topics, such as
this were looking for file conversions. One of the replies says that they found CloudConvert's API, but were having problems to get it working in Deluge.
I have attached a sample script to give you a general idea:
- rec = Writer_Test[ID == rec_id];
- header_map = Map();
- header_map.put("Authorization","Bearer API_KEY");
- header_map.put("Content-type","application/json");
- import_pram_map = Map();
- import_pram_map.put("url","https://creatorapp.zohopublic.com/file/owner/app/report/" + rec_id + "/File_upload/download/public_key?filepath=/" + rec.File_upload);
- // //import
- import = invokeurl
- [
- url :"https://api.cloudconvert.com/v2/import/url"
- type :POST
- parameters:import_pram_map
- headers:header_map
- ];
- import_task_id = import.get("data").get("id");
- //wait for import
- import_task_sync = invokeurl
- [
- url :"https://sync.api.cloudconvert.com/v2/tasks/" + import_task_id
- type :GET
- headers:header_map
- ];
- import_task_sync_id = import_task_sync.get("data").get("id");
- //convert
- convert_pram_map = Map();
- convert_pram_map.put("input",import_task_sync_id);
- convert_pram_map.put("output_format","pdf");
- convert_pram_map.put("filename", "file_name.pdf");
- convert = invokeurl
- [
- url :"https://api.cloudconvert.com/v2/convert"
- type :POST
- parameters:convert_pram_map
- headers:header_map
- ];
- convert_task_id = convert.get("data").get("id");
- // //wait for conversion
- convert_task_sync = invokeurl
- [
- url :"https://sync.api.cloudconvert.com/v2/tasks/" + convert_task_id
- type :GET
- headers:header_map
- ];
- convert_task_sync_id = convert_task_sync.get("data").get("id");
- //export
- export_pram_map = Map();
- export_pram_map.put("input",convert_task_sync_id);
- export = invokeurl
- [
- url :"https://api.cloudconvert.com/v2/export/url"
- type :POST
- parameters:export_pram_map
- headers:header_map
- ];
- export_task_id = export.get("data").get("id");
- //wait for export
- export_task_sync = invokeurl
- [
- url :"https://sync.api.cloudconvert.com/v2/tasks/" + export_task_id
- type :GET
- headers:header_map
- ];
- pdf_link = export_task_sync.get("data").get("result").get("files").getJSON("url");
- return pdf_link;
For the image URL, I have passed an image that is stored inside Creator. I am using the public link of that image.
My use case here was to create a PDF which consists of the main PDF file attached with an image at the end. Both the image and the PDF are stored in Creator. Once the files are uploaded and submitted in Creator, the image is converted to a PDF, after which I am using the Combine PDF API of Writer to get the image attached to the PDF. After that it is uploaded to Writer through its API.
One conversion consumes one credit. From what I have seen, uploading and downloading from CloudConvert consumes no credits.
Links for reference: