docx-to-pdf-axios 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,6 @@
1
+ (C) 2022 Wilson Foo Yu Kang. All rights reserved except as expressly set out hereinafter.
2
+ Unrestricted sole licence granted to Custom Automated Systems (R) Pte Ltd, revocable with express written notice by Wilson Foo Yu Kang.
3
+
4
+ Dual licensed under:
5
+ NPOSL-3.0 https://opensource.org/licenses/NPOSL-3.0
6
+ Proprietary sub-licence with Custom Automated Systems Pte Ltd (contact sales@customautosys.com to negotiate licence terms)
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # docx-to-pdf-axios
2
+
3
+ Convert docx files to pdf using http://convertonlinefree.com. Convert docx files to pdf using http://convertonlinefree.com. This fork uses axios so it is compatible with both the browser and node.
4
+
5
+ ## Copyright Notice
6
+
7
+ © 2022 Wilson Foo Yu Kang. All rights reserved except as otherwise expressly provided in writing.
8
+
9
+ Licensed by Wilson Foo Yu Kang to the sole licensee Custom Automated Systems ® Pte Ltd on private and confidential terms which may be revoked with express written notice at any time at the sole and absolute discretion of Wilson Foo Yu Kang. By using and continuing to use this package, all parties agree that they are sub-licensing this package, including where this is pursuant to the LICENSE file containing herein, from Custom Automated Systems ® Pte Ltd and are not contracting directly with Wilson Foo Yu Kang, save that Wilson Foo Yu Kang shall be availed of all protections at law including all limitations of liability. Contact sales@customautosys.com for custom licensing terms.
10
+
11
+ Removal of this Copyright Notice is prohibited.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm i -D docx-to-pdf-axios
17
+ npm i -S docx-to-pdf-axios
18
+ ```
19
+
20
+ ## Importing
21
+
22
+ ```typescript
23
+ import docxToPdfAxios from 'docx-to-pdf-axios';
24
+ ```
25
+
26
+ ## Functions
27
+
28
+ ```typescript
29
+ docxToPdfAxios(docx:Blob|Buffer):Promise<AxiosResponse<ArrayBuffer>>
30
+ ```
31
+
32
+ Converts a docx Blob (browser) or Buffer (node) to a PDF ArrayBuffer.
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ import { AxiosResponse } from 'axios';
3
+ export default function docxToPdfAxios(docx: Blob | Buffer): Promise<AxiosResponse<ArrayBuffer>>;
package/dist/index.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const browser_or_node_1 = require("browser-or-node");
39
+ const axios_1 = __importDefault(require("axios"));
40
+ function docxToPdfAxios(docx) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ let NodeFormData;
43
+ if (browser_or_node_1.isNode)
44
+ NodeFormData = (yield Promise.resolve().then(() => __importStar(require('form-data')))).default;
45
+ let formData = new (browser_or_node_1.isNode ? NodeFormData : FormData)();
46
+ formData.append('__EVENTTARGET', '');
47
+ formData.append('__EVENTARGUMENT', '');
48
+ formData.append('__VIEWSTATE', '');
49
+ formData.append('ctl00$MainContent$fu', docx, 'output.docx');
50
+ formData.append('ctl00$MainContent$btnConvert', 'Convert');
51
+ formData.append('ctl00$MainContent$fuZip', '');
52
+ let options = { responseType: 'arraybuffer' };
53
+ if (browser_or_node_1.isNode)
54
+ options.headers = formData.getHeaders();
55
+ return axios_1.default.post('http://mirror1.convertonlinefree.com', formData, options);
56
+ });
57
+ }
58
+ exports.default = docxToPdfAxios;
59
+ ;
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "docx-to-pdf-axios",
3
+ "version": "1.1.1",
4
+ "description": "Convert docx files to pdf using http://convertonlinefree.com. Convert docx files to pdf using http://convertonlinefree.com. This fork uses axios so it is compatible with both the browser and node.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "/dist"
9
+ ],
10
+ "author": "Wilson Foo Yu Kang <wilson.foo@customautosys.com>",
11
+ "license": "(NPOSL-3.0 OR UNLICENSED)",
12
+ "repository": "git+https://github.com/customautosys/docx-to-pdf-axios.git",
13
+ "bugs": {
14
+ "url": "https://github.com/customautosys/docx-to-pdf-axios/issues"
15
+ },
16
+ "homepage": "https://github.com/customautosys/docx-to-pdf-axios#readme",
17
+ "keywords": [
18
+ "docx",
19
+ "pdf",
20
+ "axios",
21
+ "convertonlinefree"
22
+ ],
23
+ "devDependencies": {
24
+ "@types/node": "^18.7.18",
25
+ "typescript": "^4.8.3"
26
+ },
27
+ "dependencies": {
28
+ "axios": "^0.27.2",
29
+ "browser-or-node": "^2.0.0",
30
+ "form-data": "^4.0.0"
31
+ }
32
+ }