2017-12-05 02:24:49 +00:00
|
|
|
/* tslint:disable:object-literal-key-quotes */
|
|
|
|
// This tslint disable is needed, or it simply won't work
|
2017-11-10 14:27:57 +00:00
|
|
|
import * as fs from "fs";
|
2017-12-05 02:24:49 +00:00
|
|
|
import * as request from "request-promise";
|
2017-09-30 18:23:02 +01:00
|
|
|
|
2017-11-10 14:27:57 +00:00
|
|
|
export interface IConvertOutput {
|
|
|
|
data: string;
|
|
|
|
}
|
|
|
|
|
2017-09-30 18:23:02 +01:00
|
|
|
export class PdfConvertWrapper {
|
2017-12-05 02:24:49 +00:00
|
|
|
public convert(filePath: string): request.RequestPromise {
|
|
|
|
return request.post({
|
|
|
|
url: "http://mirror1.convertonlinefree.com",
|
|
|
|
encoding: null,
|
|
|
|
headers: {
|
|
|
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36",
|
|
|
|
},
|
|
|
|
formData: {
|
|
|
|
"__EVENTTARGET": "",
|
|
|
|
"__EVENTARGUMENT": "",
|
|
|
|
"__VIEWSTATE": "",
|
|
|
|
"ctl00$MainContent$fu": {
|
|
|
|
value: fs.readFileSync(filePath),
|
|
|
|
options: {
|
|
|
|
filename: "output.docx",
|
|
|
|
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
|
|
},
|
2017-11-10 14:27:57 +00:00
|
|
|
},
|
2017-12-05 02:24:49 +00:00
|
|
|
"ctl00$MainContent$btnConvert": "Convert",
|
|
|
|
"ctl00$MainContent$fuZip": "",
|
|
|
|
},
|
2017-11-10 14:27:57 +00:00
|
|
|
});
|
|
|
|
}
|
2017-09-30 18:23:02 +01:00
|
|
|
}
|