Files
docx-js/src/export/packer/pdf-convert-wrapper.ts

36 lines
1.2 KiB
TypeScript
Raw Normal View History

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-11-10 14:27:57 +00:00
export interface IConvertOutput {
data: string;
}
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: {
2018-01-23 01:33:12 +00:00
"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",
2017-12-05 02:24:49 +00:00
},
formData: {
2018-01-23 01:33:12 +00:00
__EVENTTARGET: "",
__EVENTARGUMENT: "",
__VIEWSTATE: "",
ctl00$MainContent$fu: {
2017-12-05 02:24:49 +00:00
value: fs.readFileSync(filePath),
options: {
filename: "output.docx",
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
},
2017-11-10 14:27:57 +00:00
},
2018-01-23 01:33:12 +00:00
ctl00$MainContent$btnConvert: "Convert",
ctl00$MainContent$fuZip: "",
2017-12-05 02:24:49 +00:00
},
2017-11-10 14:27:57 +00:00
});
}
}