├── DotNET
├── AdvancedFeatures
│ ├── AddWatermark.cs
│ └── PDFCompression.cs
├── DocumentAI
│ ├── FormRecognizer.cs
│ ├── LayoutAnalysis.cs
│ ├── MagicColor.cs
│ ├── OCR.cs
│ ├── StampInspection.cs
│ └── TrimCorrection.cs
├── DocumentEditor
│ ├── PDFCompare.cs
│ ├── PDFDelete.cs
│ ├── PDFExtract.cs
│ ├── PDFInsert.cs
│ ├── PDFMerge.cs
│ ├── PDFRotate.cs
│ └── PDFSplit.cs
├── IMGConversion
│ ├── IMGtoCSV.cs
│ ├── IMGtoExcel.cs
│ ├── IMGtoHTML.cs
│ ├── IMGtoPPT.cs
│ ├── IMGtoRTF.cs
│ ├── IMGtoTXT.cs
│ └── IMGtoWord.cs
├── PDFConversion
│ ├── PDFtoCSV.cs
│ ├── PDFtoEditablePDF.cs
│ ├── PDFtoExcel.cs
│ ├── PDFtoHTML.cs
│ ├── PDFtoImage.cs
│ ├── PDFtoJson.cs
│ ├── PDFtoPPT.cs
│ ├── PDFtoRTF.cs
│ ├── PDFtoTXT.cs
│ └── PDFtoWord.cs
└── ToPDFConversion
│ ├── CSVToPDF.cs
│ ├── ExcelToPDF.cs
│ ├── HTMLToPDF.cs
│ ├── PNGToPDF.cs
│ ├── PPTToPDF.cs
│ ├── RTFToPDF.cs
│ ├── TXTToPDF.cs
│ └── WordToPDF.cs
├── Java
├── AdvancedFeatures
│ ├── AddWatermark.java
│ └── PDFCompression.java
├── DocumentAI
│ ├── FormRecognizer.java
│ ├── LayoutAnalysis.java
│ ├── MagicColor.java
│ ├── OCR.java
│ ├── StampInspection.java
│ └── TrimCorrection.java
├── DocumentEditor
│ ├── PDFCompare.java
│ ├── PDFDelete.java
│ ├── PDFExtract.java
│ ├── PDFInsert.java
│ ├── PDFMerge.java
│ ├── PDFRotate.java
│ └── PDFSplit.java
├── IMGConversion
│ ├── IMGtoCSV.java
│ ├── IMGtoExcel.java
│ ├── IMGtoHTML.java
│ ├── IMGtoPPT.java
│ ├── IMGtoRTF.java
│ ├── IMGtoTXT.java
│ └── IMGtoWord.java
├── PDFConversion
│ ├── PDFtoCSV.java
│ ├── PDFtoEditablePDF.java
│ ├── PDFtoExcel.java
│ ├── PDFtoHTML.java
│ ├── PDFtoImage.java
│ ├── PDFtoJson.java
│ ├── PDFtoPPT.java
│ ├── PDFtoRTF.java
│ ├── PDFtoTXT.java
│ └── PDFtoWord.java
├── ToPDFConversion
│ ├── CSVToPDF.java
│ ├── ExcelToPDF.java
│ ├── HTMLToPDF.java
│ ├── PNGToPDF.java
│ ├── PPTToPDF.java
│ ├── RTFToPDF.java
│ ├── TXTToPDF.java
│ └── WordToPDF.java
└── pom.xml
├── JavaScript
├── AdvancedFeatures
│ ├── AddWatermark.js
│ └── PDFCompression.js
├── DocumentAI
│ ├── FormRecognizer.js
│ ├── LayoutAnalysis.js
│ ├── MagicColor.js
│ ├── OCR.js
│ ├── StampInspection.js
│ └── TrimCorrection.js
├── DocumentEditor
│ ├── PDFCompare.js
│ ├── PDFDelete.js
│ ├── PDFExtract.js
│ ├── PDFInsert.js
│ ├── PDFMerge.js
│ ├── PDFRotate.js
│ └── PDFSplit.js
├── IMGConversion
│ ├── IMGtoCSV.js
│ ├── IMGtoExcel.js
│ ├── IMGtoHTML.js
│ ├── IMGtoPPT.js
│ ├── IMGtoRTF.js
│ ├── IMGtoTXT.js
│ └── IMGtoWord.js
├── PDFConversion
│ ├── PDFtoCSV.js
│ ├── PDFtoEditablePDF.js
│ ├── PDFtoExcel.js
│ ├── PDFtoHTML.js
│ ├── PDFtoImage.js
│ ├── PDFtoJson.js
│ ├── PDFtoPPT.js
│ ├── PDFtoRTF.js
│ ├── PDFtoTXT.js
│ └── PDFtoWord.js
└── ToPDFConversion
│ ├── CSVToPDF.js
│ ├── ExcelToPDF.js
│ ├── HTMLToPDF.js
│ ├── PNGToPDF.js
│ ├── PPTToPDF.js
│ ├── RTFToPDF.js
│ ├── TXTToPDF.js
│ └── WordToPDF.js
├── LICENSE
├── PHP
├── AdvancedFeatures
│ ├── AddWatermark.php
│ └── PDFCompression.php
├── DocumentAI
│ ├── FormRecognizer.php
│ ├── LayoutAnalysis.php
│ ├── MagicColor.php
│ ├── OCR.php
│ ├── StampInspection.php
│ └── TrimCorrection.php
├── DocumentEditor
│ ├── PDFCompare.php
│ ├── PDFDelete.php
│ ├── PDFExtract.php
│ ├── PDFInsert.php
│ ├── PDFMerge.php
│ ├── PDFRotate.php
│ └── PDFSplit.php
├── IMGConversion
│ ├── IMGtoCSV.php
│ ├── IMGtoExcel.php
│ ├── IMGtoHTML.php
│ ├── IMGtoPPT.php
│ ├── IMGtoRTF.php
│ ├── IMGtoTXT.php
│ └── IMGtoWord.php
├── PDFConversion
│ ├── PDFToWord.php
│ ├── PDFtoCSV.php
│ ├── PDFtoEditablePDF.php
│ ├── PDFtoExcel.php
│ ├── PDFtoHTML.php
│ ├── PDFtoImage.php
│ ├── PDFtoJson.php
│ ├── PDFtoPPT.php
│ ├── PDFtoRTF.php
│ └── PDFtoTXT.php
└── ToPDFConversion
│ ├── CSVToPDF.php
│ ├── ExcelToPDF.php
│ ├── HTMLToPDF.php
│ ├── PNGToPDF.php
│ ├── PPTToPDF.php
│ ├── RTFToPDF.php
│ ├── TXTToPDF.php
│ └── WordToPDF.php
├── Python
├── AdvancedFeatures
│ ├── AddWatermark.py
│ └── PDFCompression.py
├── DocumentAI
│ ├── FormRecognizer.py
│ ├── LayoutAnalysis.py
│ ├── MagicColor.py
│ ├── OCR.py
│ ├── StampInspection.py
│ └── TrimCorrection.py
├── DocumentEditor
│ ├── PDFCompare.py
│ ├── PDFDelete.py
│ ├── PDFExtract.py
│ ├── PDFInsert.py
│ ├── PDFMerge.py
│ ├── PDFRotate.py
│ └── PDFSplit.py
├── IMGConversion
│ ├── IMGtoCSV.py
│ ├── IMGtoExcel.py
│ ├── IMGtoHTML.py
│ ├── IMGtoPPT.py
│ ├── IMGtoRTF.py
│ ├── IMGtoTXT.py
│ └── IMGtoWord.py
├── PDFConversion
│ ├── PDFToWord.py
│ ├── PDFtoCSV.py
│ ├── PDFtoEditablePDF.py
│ ├── PDFtoExcel.py
│ ├── PDFtoHTML.py
│ ├── PDFtoImage.py
│ ├── PDFtoJson.py
│ ├── PDFtoPPT.py
│ ├── PDFtoRTF.py
│ └── PDFtoTXT.py
└── ToPDFConversion
│ ├── CSVToPDF.py
│ ├── ExcelToPDF.py
│ ├── HTMLToPDF.py
│ ├── PNGToPDF.py
│ ├── PPTToPDF.py
│ ├── RTFToPDF.py
│ ├── TXTToPDF.py
│ └── WordToPDF.py
├── README.md
└── cURL
├── AdvancedFeatures
├── AddWatermark.sh
└── PDFCompression.sh
├── DocumentAI
├── FormRecognizer.sh
├── LayoutAnalysis.sh
├── MagicColor.sh
├── OCR.sh
├── StampInspection.sh
└── TrimCorrection.sh
├── DocumentEditor
├── PDFCompare.sh
├── PDFDelete.sh
├── PDFExtract.sh
├── PDFInsert.sh
├── PDFMerge.sh
├── PDFRotate.sh
└── PDFSplit.sh
├── IMGConversion
├── IMGtoCSV.sh
├── IMGtoExcel.sh
├── IMGtoHTML.sh
├── IMGtoPPT.sh
├── IMGtoRTF.sh
├── IMGtoTXT.sh
└── IMGtoWord.sh
├── PDFConversion
├── PDFtoCSV.sh
├── PDFtoEditablePDF.sh
├── PDFtoExcel.sh
├── PDFtoHTML.sh
├── PDFtoImage.sh
├── PDFtoJson.sh
├── PDFtoPPT.sh
├── PDFtoRTF.sh
├── PDFtoTXT.sh
└── PDFtoWord.sh
└── ToPDFConversion
├── CSVToPDF.sh
├── ExcelToPDF.sh
├── HTMLToPDF.sh
├── PNGToPDF.sh
├── PPTToPDF.sh
├── RTFToPDF.sh
├── TXTToPDF.sh
└── WordToPDF.sh
/Java/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | cd.kdan
6 | compdfkit-api-samples
7 | 1.0-SNAPSHOT
8 |
9 |
10 | 8
11 | 8
12 | UTF-8
13 |
14 |
15 |
16 |
17 | com.squareup.okhttp3
18 | okhttp
19 | 4.9.3
20 |
21 |
22 | org.json
23 | json
24 | 20230618
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/JavaScript/AdvancedFeatures/PDFCompression.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pdf/compress?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{"quality":"50"}');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/DocumentAI/FormRecognizer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/documentAI/tableRec?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "lang": "1" }');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/DocumentAI/LayoutAnalysis.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/documentAI/layoutAnalysis?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: pdfData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/DocumentAI/MagicColor.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/documentAI/magicColor?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: pdfData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/DocumentAI/OCR.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/documentAI/ocr?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "lang": "1" }');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/DocumentAI/StampInspection.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/documentAI/detectionStamp?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: pdfData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/DocumentAI/TrimCorrection.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/documentAI/dewarp?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: pdfData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/DocumentEditor/PDFDelete.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pdf/delete?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "pageOptions":["1","3-4"] }');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/DocumentEditor/PDFExtract.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pdf/extract?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "pageOptions":["1","3-4"] }');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/DocumentEditor/PDFSplit.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pdf/split?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "pageOptions":["1","2-3"] }');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/IMGConversion/IMGtoRTF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/img/rtf?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "isAllowOcr":1,"isContainOcrBg":0 }');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/IMGConversion/IMGtoTXT.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/img/txt?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "isAllowOcr":1,"isContainOcrBg":0 }');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/PDFConversion/PDFtoCSV.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pdf/csv?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "isCsvMerge": "1" }');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/PDFConversion/PDFtoEditablePDF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pdf/editable?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "lang": "1"}');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/PDFConversion/PDFtoImage.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pdf/jpg?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "imgDpi": "300","pages":[1] }');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/PDFConversion/PDFtoJson.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pdf/json?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "type": 1, "isAllowOcr":0, "isContainOcrBg":0}');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/PDFConversion/PDFtoTXT.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pdf/txt?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const pdfFile = document.getElementById('pdfFileInput').files[0];
44 | if (!pdfFile) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const pdfData = new FormData();
49 | pdfData.append('file', pdfFile, pdfFile.name);
50 | pdfData.append('taskId', taskId);
51 | pdfData.append('parameter', '{ "isAllowOcr":0,"isContainOcrBg":0}');
52 | pdfData.append('language', '2');
53 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
54 | method: 'POST',
55 | headers: {
56 | 'Authorization': `Bearer ${accessToken}`,
57 | },
58 | body: pdfData
59 | });
60 | const uploadFileData = await uploadFileResponse.json();
61 | console.log('File uploaded successfully.');
62 |
63 | // 4. Execute Task
64 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
65 | method: 'GET',
66 | headers: {
67 | 'Authorization': `Bearer ${accessToken}`,
68 | }
69 | });
70 | const executeTaskData = await executeTaskResponse.json();
71 | console.log('Task execution started.');
72 |
73 | // 5. Get Task Information
74 | let taskCompleted = false;
75 | while (!taskCompleted) {
76 | await new Promise(resolve => setTimeout(resolve, 1000));
77 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
78 | method: 'GET',
79 | headers: {
80 | 'Authorization': `Bearer ${accessToken}`,
81 | }
82 | });
83 | const taskInfoData = await taskInfoResponse.json();
84 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
85 | taskCompleted = true;
86 | console.log('Task Information:', taskInfoData);
87 | }
88 | }
89 | console.log('Task completed.');
90 | });
--------------------------------------------------------------------------------
/JavaScript/ToPDFConversion/CSVToPDF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/csv/pdf?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const file = document.getElementById('fileInput').files[0];
44 | if (!file) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const formData = new FormData();
49 | formData.append('file', file, file.name);
50 | formData.append('taskId', taskId);
51 | formData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: formData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/ToPDFConversion/ExcelToPDF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/xlsx/pdf?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const file = document.getElementById('fileInput').files[0];
44 | if (!file) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const formData = new FormData();
49 | formData.append('file', file, file.name);
50 | formData.append('taskId', taskId);
51 | formData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: formData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/ToPDFConversion/HTMLToPDF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/html/pdf?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const file = document.getElementById('fileInput').files[0];
44 | if (!file) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const formData = new FormData();
49 | formData.append('file', file, file.name);
50 | formData.append('taskId', taskId);
51 | formData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: formData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/ToPDFConversion/PNGToPDF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/png/pdf?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const file = document.getElementById('fileInput').files[0];
44 | if (!file) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const formData = new FormData();
49 | formData.append('file', file, file.name);
50 | formData.append('taskId', taskId);
51 | formData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: formData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/ToPDFConversion/PPTToPDF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/pptx/pdf?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const file = document.getElementById('fileInput').files[0];
44 | if (!file) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const formData = new FormData();
49 | formData.append('file', file, file.name);
50 | formData.append('taskId', taskId);
51 | formData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: formData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/ToPDFConversion/RTFToPDF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/rtf/pdf?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const file = document.getElementById('fileInput').files[0];
44 | if (!file) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const formData = new FormData();
49 | formData.append('file', file, file.name);
50 | formData.append('taskId', taskId);
51 | formData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: formData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/ToPDFConversion/TXTToPDF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/txt/pdf?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const file = document.getElementById('fileInput').files[0];
44 | if (!file) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const formData = new FormData();
49 | formData.append('file', file, file.name);
50 | formData.append('taskId', taskId);
51 | formData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: formData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/JavaScript/ToPDFConversion/WordToPDF.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Upload file form
3 | *
4 |
8 | *
9 | */
10 |
11 | async function authenticate() {
12 | const authResponse = await fetch('https://api-server.compdf.com/server/v1/oauth/token', {
13 | method: 'POST',
14 | headers: {
15 | 'Content-Type': 'application/json'
16 | },
17 | body: JSON.stringify({
18 | publicKey: 'public_key_******',
19 | secretKey: 'secret_key_******'
20 | })
21 | });
22 | const authData = await authResponse.json();
23 | return authData.data.accessToken;
24 | }
25 |
26 | document.getElementById('uploadForm').addEventListener('submit', async function (event) {
27 | event.preventDefault();
28 |
29 | // 1.Authenticatio
30 | const accessToken = await authenticate();
31 |
32 | // 2.Create Task
33 | const createTaskResponse = await fetch('https://api-server.compdf.com/server/v1/task/docx/pdf?language=2', {
34 | method: 'GET',
35 | headers: {
36 | 'Authorization': `Bearer ${accessToken}`,
37 | }
38 | });
39 | const createTaskData = await createTaskResponse.json();
40 | const taskId = createTaskData.data.taskId;
41 |
42 | // 3.Upload File
43 | const file = document.getElementById('fileInput').files[0];
44 | if (!file) {
45 | alert('Please select a PDF file to upload.');
46 | return;
47 | }
48 | const formData = new FormData();
49 | formData.append('file', file, file.name);
50 | formData.append('taskId', taskId);
51 | formData.append('language', '2');
52 | const uploadFileResponse = await fetch('https://api-server.compdf.com/server/v1/file/upload', {
53 | method: 'POST',
54 | headers: {
55 | 'Authorization': `Bearer ${accessToken}`,
56 | },
57 | body: formData
58 | });
59 | const uploadFileData = await uploadFileResponse.json();
60 | console.log('File uploaded successfully.');
61 |
62 | // 4. Execute Task
63 | const executeTaskResponse = await fetch(`https://api-server.compdf.com/server/v1/execute/start?language=2&taskId=${taskId}`, {
64 | method: 'GET',
65 | headers: {
66 | 'Authorization': `Bearer ${accessToken}`,
67 | }
68 | });
69 | const executeTaskData = await executeTaskResponse.json();
70 | console.log('Task execution started.');
71 |
72 | // 5. Get Task Information
73 | let taskCompleted = false;
74 | while (!taskCompleted) {
75 | await new Promise(resolve => setTimeout(resolve, 1000));
76 | const taskInfoResponse = await fetch(`https://api-server.compdf.com/server/v1/task/taskInfo?taskId=${taskId}`, {
77 | method: 'GET',
78 | headers: {
79 | 'Authorization': `Bearer ${accessToken}`,
80 | }
81 | });
82 | const taskInfoData = await taskInfoResponse.json();
83 | if (taskInfoData.data.taskStatus === 'TaskFinish') {
84 | taskCompleted = true;
85 | console.log('Task Information:', taskInfoData);
86 | }
87 | }
88 | console.log('Task completed.');
89 | });
--------------------------------------------------------------------------------
/Python/AdvancedFeatures/AddWatermark.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/addWatermark?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{"type": "text","scale":"1","opacity":"0.5","rotation":"0.785","targetPages":"1","vertalign":"center","horizalign":"left","xoffset":"100","yoffset":"100","content":"test","textColor":"#59c5bb","front":"1","fullScreen":"1","horizontalSpace":"10","verticalSpace":"10","extension":""}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/AdvancedFeatures/PDFCompression.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/compress?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{"quality":"50"}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentAI/FormRecognizer.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/documentAI/tableRec?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "lang": "1" }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentAI/LayoutAnalysis.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/documentAI/layoutAnalysis?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentAI/MagicColor.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/documentAI/magicColor?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentAI/OCR.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/documentAI/ocr?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "lang": "1" }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentAI/StampInspection.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/documentAI/detectionStamp?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentAI/TrimCorrection.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/documentAI/dewarp?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentEditor/PDFCompare.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path1 = "input_files/compare1.pdf"
5 | pdf_path2 = "input_files/compare2.pdf"
6 | public_key = "public_key_******"
7 | secret_key = "secret_key_******"
8 |
9 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
10 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
11 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
12 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
13 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
14 |
15 | # 1. Authentication
16 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
17 | auth_response = requests.post(AUTH_URL, json=auth_payload)
18 | auth_data = auth_response.json()
19 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
20 | print("bearerToken:", bearer_token)
21 |
22 | # 2. Create Task
23 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/contentCompare?language=2", headers={"Authorization": bearer_token})
24 | create_task_data = create_task_response.json()
25 | task_id = create_task_data["data"]["taskId"]
26 | print("taskId:", task_id)
27 |
28 | # Upload File
29 | with open(pdf_path1, "rb") as file1:
30 | files = {
31 | 'file': ('compare1.pdf', file1, 'application/octet-stream'),
32 | }
33 | upload_payload = {
34 | "taskId": task_id,
35 | "parameter": '{ "imgCompare":"1", "isSaveTwo":"0", "textCompare":"1", "replaceColor":"#FF0000", "insertColor":"#00FF00", "deleteColor":"#0000FF"}',
36 | "language": "2"
37 | }
38 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
39 | print("Upload File Result:", upload_file_response.json())
40 | # Upload File2
41 | with open(pdf_path2, "rb") as file2:
42 | files = {
43 | 'file': ('compare2.pdf', file2, 'application/octet-stream'),
44 | }
45 | upload_payload = {
46 | "taskId": task_id,
47 | "parameter": '{ "imgCompare":"1", "isSaveTwo":"0", "textCompare":"1", "replaceColor":"#FF0000", "insertColor":"#00FF00", "deleteColor":"#0000FF"}',
48 | "language": "2"
49 | }
50 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
51 | print("Upload File Result:", upload_file_response.json())
52 |
53 | # 4. Execute Task
54 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
55 | print("Execute Task Result:", execute_task_response.json())
56 |
57 | # 5. Get Task Information
58 | flag = True
59 | while flag:
60 | time.sleep(1)
61 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
62 | task_info_data = task_info_response.json()
63 | task_status = task_info_data["data"]["taskStatus"]
64 | if task_status == "TaskFinish":
65 | print("Task Information:", task_info_data)
66 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentEditor/PDFDelete.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/delete?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{"pageOptions":["1","3-4"]}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentEditor/PDFExtract.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/extract?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{"pageOptions":["1","3-4"]}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentEditor/PDFInsert.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/insert?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{"targetPage": "2","width": "500","height": "800", "number": "2"}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentEditor/PDFMerge.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path1 = "input_files/compare1.pdf"
5 | pdf_path2 = "input_files/compare2.pdf"
6 | public_key = "public_key_******"
7 | secret_key = "secret_key_******"
8 |
9 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
10 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
11 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
12 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
13 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
14 |
15 | # 1. Authentication
16 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
17 | auth_response = requests.post(AUTH_URL, json=auth_payload)
18 | auth_data = auth_response.json()
19 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
20 | print("bearerToken:", bearer_token)
21 |
22 | # 2. Create Task
23 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/merge?language=2", headers={"Authorization": bearer_token})
24 | create_task_data = create_task_response.json()
25 | task_id = create_task_data["data"]["taskId"]
26 | print("taskId:", task_id)
27 |
28 | # Upload File
29 | with open(pdf_path1, "rb") as file1:
30 | files = {
31 | 'file': ('compare1.pdf', file1, 'application/octet-stream'),
32 | }
33 | upload_payload = {
34 | "taskId": task_id,
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 | # Upload File2
40 | with open(pdf_path2, "rb") as file2:
41 | files = {
42 | 'file': ('compare2.pdf', file2, 'application/octet-stream'),
43 | }
44 | upload_payload = {
45 | "taskId": task_id,
46 | "language": "2"
47 | }
48 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
49 | print("Upload File Result:", upload_file_response.json())
50 |
51 | # 4. Execute Task
52 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
53 | print("Execute Task Result:", execute_task_response.json())
54 |
55 | # 5. Get Task Information
56 | flag = True
57 | while flag:
58 | time.sleep(1)
59 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
60 | task_info_data = task_info_response.json()
61 | task_status = task_info_data["data"]["taskStatus"]
62 | if task_status == "TaskFinish":
63 | print("Task Information:", task_info_data)
64 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentEditor/PDFRotate.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/rotation?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "pageOptions": "[\'2\']", "rotation":"90" }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/DocumentEditor/PDFSplit.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/split?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "pageOptions":["1","2-3"] }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/IMGConversion/IMGtoCSV.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/img/csv?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "isCsvMerge": 1 ,"isAllowOcr":1, "isOnlyAiTable":0 }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/IMGConversion/IMGtoExcel.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/img/xlsx?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "contentOptions": "2", "worksheetOptions": "1", "isAllowOcr": 1,"isContainOcrBg":0,"isOnlyAiTable":0}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/IMGConversion/IMGtoHTML.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/img/html?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "pageOptions": 1 , "isAllowOcr":1,"isContainOcrBg":0,"isOnlyAiTable":0}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/IMGConversion/IMGtoPPT.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/img/pptx?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "isAllowOcr":1,"isContainOcrBg":0,"isOnlyAiTable":0 }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/IMGConversion/IMGtoRTF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/img/rtf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "isAllowOcr":1,"isContainOcrBg":0 }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/IMGConversion/IMGtoTXT.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/img/txt?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "isAllowOcr":1,"isContainOcrBg":0 }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/IMGConversion/IMGtoWord.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/img/docx?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "wordLayoutMode":2,"isAllowOcr":0,"isContainOcrBg":0,"isOnlyAiTable":0 }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFToWord.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/docx?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{"isContainAnnot": 1, "isContainImg": 1, "wordLayoutMode": 2, "isAllowOcr": 0, "isContainOcrBg": 0, "isOnlyAiTable": 0, "ocrLanguage": 0}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFtoCSV.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/csv?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "isCsvMerge": "1" }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFtoEditablePDF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/editable?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "lang": "1"}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFtoExcel.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/xlsx?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "contentOptions": "2", "worksheetOptions": "1", "isContainAnnot": 1, "isContainImg": 1,"isAllowOcr":0,"isContainOcrBg":0,"isOnlyAiTable":0}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFtoHTML.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/html?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "pageOptions": 1 , "isContainAnnot": 1 , "isContainImg": 1,"isAllowOcr":0,"isContainOcrBg":1,"isOnlyAiTable":0}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFtoImage.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/jpg?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "imgDpi": "300","pages":[1] }',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFtoJson.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/json?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "type": 1, "isAllowOcr":0, "isContainOcrBg":0}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFtoPPT.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/pptx?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "isContainAnnot": 1 , "isContainImg": 1,"isAllowOcr":0,"isContainOcrBg":0,"isOnlyAiTable":0}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFtoRTF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/rtf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "isContainAnnot": 1 , "isContainImg": 1,"isAllowOcr":0,"isContainOcrBg":0}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/PDFConversion/PDFtoTXT.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/file.pdf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pdf/txt?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('file.pdf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "parameter": '{ "isAllowOcr":0,"isContainOcrBg":0}',
35 | "language": "2"
36 | }
37 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
38 | print("Upload File Result:", upload_file_response.json())
39 |
40 | # 4. Execute Task
41 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
42 | print("Execute Task Result:", execute_task_response.json())
43 |
44 | # 5. Get Task Information
45 | flag = True
46 | while flag:
47 | time.sleep(1)
48 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
49 | task_info_data = task_info_response.json()
50 | task_status = task_info_data["data"]["taskStatus"]
51 | if task_status == "TaskFinish":
52 | print("Task Information:", task_info_data)
53 | flag = False
--------------------------------------------------------------------------------
/Python/ToPDFConversion/CSVToPDF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/csv.csv"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/csv/pdf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('csv.csv', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/ToPDFConversion/ExcelToPDF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/excel.xlsx"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/xlsx/pdf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('excel.xlsx', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/ToPDFConversion/HTMLToPDF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/html.html"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/html/pdf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('html.html', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/ToPDFConversion/PNGToPDF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/test.png"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/png/pdf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('test.png', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/ToPDFConversion/PPTToPDF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/ppt.pptx"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/pptx/pdf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('ppt.pptx', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/ToPDFConversion/RTFToPDF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/rtf.rtf"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/rtf/pdf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('rtf.rtf', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/ToPDFConversion/TXTToPDF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/txt.txt"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/txt/pdf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('txt.txt', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/Python/ToPDFConversion/WordToPDF.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import time
3 |
4 | pdf_path = "input_files/word.docx"
5 | public_key = "public_key_******"
6 | secret_key = "secret_key_******"
7 |
8 | AUTH_URL = "https://api-server.compdf.com/server/v1/oauth/token"
9 | CREATE_TASK_URL = "https://api-server.compdf.com/server/v1/task"
10 | UPLOAD_FILE_URL = "https://api-server.compdf.com/server/v1/file/upload"
11 | EXECUTE_TASK_URL = "https://api-server.compdf.com/server/v1/execute/start"
12 | GET_TASK_INFO_URL = "https://api-server.compdf.com/server/v1/task/taskInfo"
13 |
14 | # 1. Authentication
15 | auth_payload = {"publicKey": public_key, "secretKey": secret_key}
16 | auth_response = requests.post(AUTH_URL, json=auth_payload)
17 | auth_data = auth_response.json()
18 | bearer_token = "Bearer " + auth_data["data"]["accessToken"]
19 | print("bearerToken:", bearer_token)
20 |
21 | # 2. Create Task
22 | create_task_response = requests.get(CREATE_TASK_URL + "/docx/pdf?language=2", headers={"Authorization": bearer_token})
23 | create_task_data = create_task_response.json()
24 | task_id = create_task_data["data"]["taskId"]
25 | print("taskId:", task_id)
26 |
27 | # 3. Upload File
28 | with open(pdf_path, "rb") as file:
29 | files = {
30 | 'file': ('word.docx', file, 'application/octet-stream'),
31 | }
32 | upload_payload = {
33 | "taskId": task_id,
34 | "language": "2"
35 | }
36 | upload_file_response = requests.post(UPLOAD_FILE_URL, files=files, data=upload_payload, headers={"Authorization": bearer_token})
37 | print("Upload File Result:", upload_file_response.json())
38 |
39 | # 4. Execute Task
40 | execute_task_response = requests.get(EXECUTE_TASK_URL + "?language=2&taskId=" + task_id, headers={"Authorization": bearer_token})
41 | print("Execute Task Result:", execute_task_response.json())
42 |
43 | # 5. Get Task Information
44 | flag = True
45 | while flag:
46 | time.sleep(1)
47 | task_info_response = requests.get(GET_TASK_INFO_URL + "?taskId=" + task_id, headers={"Authorization": bearer_token})
48 | task_info_data = task_info_response.json()
49 | task_status = task_info_data["data"]["taskStatus"]
50 | if task_status == "TaskFinish":
51 | print("Task Information:", task_info_data)
52 | flag = False
--------------------------------------------------------------------------------
/cURL/AdvancedFeatures/AddWatermark.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/documentAI/pdf/addWatermark?language=2' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/compare1.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"type\": \"text\", \"scale\": \"1\", \"opacity\":\"0.5\", \"rotation\":\"0.785\", \"targetPages\":\"1-2\", \"vertalign\":\"center\", \"horizalign\":\"left\", \"xoffset\":\"100\", \"yoffset\":\"100\", \"content\":\"test\", \"textColor\":\"#59c5bb\", \"front\":\"1\", \"fullScreen\":\"1\", \"horizontalSpace\":\"10\", \"verticalSpace\":\"10\", \"extension\":\"\"}"'
20 |
21 | # 4. Execute Task
22 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
23 | --header 'Authorization: Bearer accessToken'
24 |
25 | # 5. Get Task Information
26 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
27 | --header 'Authorization: Bearer accessToken'
28 |
--------------------------------------------------------------------------------
/cURL/AdvancedFeatures/PDFCompression.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/documentAI/pdf/compress?language=2' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/compare1.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"quality\":\"50\"}"' \
20 |
21 | # 4. Execute Task
22 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
23 | --header 'Authorization: Bearer accessToken'
24 |
25 | # 5. Get Task Information
26 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
27 | --header 'Authorization: Bearer accessToken'
28 |
--------------------------------------------------------------------------------
/cURL/DocumentAI/FormRecognizer.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/documentAI/tableRec?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"lang\": \"auto\" }"'
20 |
21 | # 4. Execute Task
22 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
23 | --header 'Authorization: Bearer accessToken'
24 |
25 | # 5. Get Task Information
26 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
27 | --header 'Authorization: Bearer accessToken'
28 |
--------------------------------------------------------------------------------
/cURL/DocumentAI/LayoutAnalysis.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/documentAI/layoutAnalysis?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/DocumentAI/MagicColor.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/documentAI/magicColor?language=2' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/DocumentAI/OCR.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/documentAI/ocr?language=2' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"lang\": \"auto\" }"'
20 |
21 | # 4. Execute Task
22 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
23 | --header 'Authorization: Bearer accessToken'
24 |
25 | # 5. Get Task Information
26 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
27 | --header 'Authorization: Bearer accessToken'
28 |
--------------------------------------------------------------------------------
/cURL/DocumentAI/StampInspection.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/documentAI/detectionStamp?language=2' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/DocumentAI/TrimCorrection.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/documentAI/dewarp?language=2' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/DocumentEditor/PDFCompare.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/contentCompare?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/compare1.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"imgCompare\": \"\", \"isSaveTwo\": \"\", \"textCompare\": \"\", \"replaceColor\": \"\", \"insertColor\": \"\", \"deleteColor\":\"\" }"' \
20 | --form 'language=""'
21 |
22 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
23 | --header 'Authorization: Bearer accessToken' \
24 | --form 'file=@"/input_files/compare2.pdf"' \
25 | --form 'taskId="taskId"' \
26 | --form 'password=""' \
27 | --form 'parameter="{ \"imgCompare\": \"\", \"isSaveTwo\": \"\", \"textCompare\": \"\", \"replaceColor\": \"\", \"insertColor\": \"\", \"deleteColor\":\"\" }"' \
28 | --form 'language=""'
29 |
30 | # 4. Execute Task
31 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
32 | --header 'Authorization: Bearer accessToken'
33 |
34 | # 5. Get Task Information
35 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
36 | --header 'Authorization: Bearer accessToken'
37 |
--------------------------------------------------------------------------------
/cURL/DocumentEditor/PDFDelete.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/delete?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/pages.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"pageOptions\": \"['\''1'\'']\"}"' \
20 |
21 | # 4. Execute Task
22 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
23 | --header 'Authorization: Bearer accessToken'
24 |
25 | # 5. Get Task Information
26 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
27 | --header 'Authorization: Bearer accessToken'
28 |
--------------------------------------------------------------------------------
/cURL/DocumentEditor/PDFExtract.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/extract?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 | a'a
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/pages.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"pageOptions\": \"['\''1'\'']\"}"'
20 |
21 | # 4. Execute Task
22 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
23 | --header 'Authorization: Bearer accessToken'
24 |
25 | # 5. Get Task Information
26 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
27 | --header 'Authorization: Bearer accessToken'
28 |
--------------------------------------------------------------------------------
/cURL/DocumentEditor/PDFInsert.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/insert?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/pages.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"targetPage\": \"1\", \"width\": \"500\", \"height\":\"800\", \"number\":\"2\"}"'
20 |
21 | # 4. Execute Task
22 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
23 | --header 'Authorization: Bearer accessToken'
24 |
25 | # 5. Get Task Information
26 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
27 | --header 'Authorization: Bearer accessToken'
28 |
--------------------------------------------------------------------------------
/cURL/DocumentEditor/PDFRotate.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/rotation?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/pages.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"pageOptions\": \"['\''1'\'']\",\"rotation\":\"90\"}"'
20 |
21 | # 4. Execute Task
22 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
23 | --header 'Authorization: Bearer accessToken'
24 |
25 | # 5. Get Task Information
26 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
27 | --header 'Authorization: Bearer accessToken'
28 |
--------------------------------------------------------------------------------
/cURL/DocumentEditor/PDFSplit.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/split?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/pages.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{\"pageOptions\":[\"1\",\"2\"]}"'
20 |
21 | # 4. Execute Task
22 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
23 | --header 'Authorization: Bearer accessToken'
24 |
25 | # 5. Get Task Information
26 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
27 | --header 'Authorization: Bearer accessToken'
28 |
--------------------------------------------------------------------------------
/cURL/IMGConversion/IMGtoCSV.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/img/csv?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"wordLayoutMode\":1, \"isAllowOcr\":1, \"isContainOcrBg\":0, \"isOnlyAiTable\":0 }"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/IMGConversion/IMGtoExcel.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/img/xlsx?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isCsvMerge\": 1 ,\"isAllowOcr\":1, \"isOnlyAiTable\":0 }"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/IMGConversion/IMGtoHTML.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/img/html?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isCsvMerge\": 1 ,\"isAllowOcr\":1, \"isOnlyAiTable\":0 }"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/IMGConversion/IMGtoPPT.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/img/ppt?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isAllowOcr\":1,\"isContainOcrBg\":0,\"isOnlyAiTable\":0}"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/IMGConversion/IMGtoRTF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/img/rtf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isAllowOcr\":1,\"isContainOcrBg\":0 }"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/IMGConversion/IMGtoTXT.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/img/txt?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isAllowOcr\":1,\"isContainOcrBg\":1}"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/IMGConversion/IMGtoWord.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/img/docx?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"wordLayoutMode\":1, \"isAllowOcr\":1, \"isContainOcrBg\":0, \"isOnlyAiTable\":0 }"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoCSV.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/csv?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/excel.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isCsvMerge\": 1 }"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoEditablePDF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/editable?language=2' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/excel.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"lang\":1 }"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoExcel.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/xlsx?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/excel.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"contentOptions\": \"2\", \"worksheetOptions\": \"1\", \"isContainAnnot\": 1 , \"isContainImg\": 1,\"isAllowOcr\":0,\"isContainOcrBg\":0,\"isOnlyAiTable\":0}"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoHTML.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/html?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"pageOptions\": 1 , \"isContainAnnot\": 1 , \"isContainImg\": 0,\"isAllowOcr\":0,\"isContainOcrBg\":0,\"isOnlyAiTable\":0}"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoImage.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/jpg?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"imgDpi\": \"300\",\"pages\":[1,3]}"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoJson.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/json?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"type\": 2, \"isAllowOcr\":0 }"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoPPT.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/pptx?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isContainAnnot\": 1 , \"isContainImg\": 1,\"isAllowOcr\":0,\"isContainOcrBg\":0,\"isOnlyAiTable\":0}"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoRTF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/rtf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isContainAnnot\": 1 , \"isContainImg\": 1,\"isAllowOcr\":0,\"isContainOcrBg\":0}"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoTXT.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/txt?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/test.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isAllowOcr\":0,\"isContainOcrBg\":0}"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/PDFConversion/PDFtoWord.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pdf/docx?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"/input_files/word.pdf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'password=""' \
19 | --form 'parameter="{ \"isContainAnnot\": 1 , \"isContainImg\": 1,\"wordLayoutMode\":1,\"isAllowOcr\":0,\"isContainOcrBg\":0,\"isOnlyAiTable\":0}"' \
20 | --form 'language=""'
21 |
22 | # 4. Execute Task
23 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
24 | --header 'Authorization: Bearer accessToken'
25 |
26 | # 5. Get Task Information
27 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
28 | --header 'Authorization: Bearer accessToken'
29 |
--------------------------------------------------------------------------------
/cURL/ToPDFConversion/CSVToPDF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/csv/pdf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"input_files/csv.csv"' \
17 | --form 'taskId="taskId"' \
18 | --form 'language="1"'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/ToPDFConversion/ExcelToPDF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/xlsx/pdf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"input_files/xlsx.xlsx"' \
17 | --form 'taskId="taskId"' \
18 | --form 'language="1"'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/ToPDFConversion/HTMLToPDF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/html/pdf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"input_files/html.html"' \
17 | --form 'taskId="taskId"' \
18 | --form 'language="1"'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/ToPDFConversion/PNGToPDF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/png/pdf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"input_files/png.png"' \
17 | --form 'taskId="taskId"' \
18 | --form 'language="1"'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/ToPDFConversion/PPTToPDF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/pptx/pdf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"input_files/pptx.pptx"' \
17 | --form 'taskId="taskId"' \
18 | --form 'language="1"'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/ToPDFConversion/RTFToPDF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/rtf/pdf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"input_files/rtf.rtf"' \
17 | --form 'taskId="taskId"' \
18 | --form 'language="1"'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------
/cURL/ToPDFConversion/TXTToPDF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/txt/pdf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"input_files/txt.txt"' \
17 | --form 'taskId="taskId"' \
18 | --form 'language="1"'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 |
23 | # 5. Get Task Information
24 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
25 | --header 'Authorization: Bearer accessToken'
26 |
--------------------------------------------------------------------------------
/cURL/ToPDFConversion/WordToPDF.sh:
--------------------------------------------------------------------------------
1 | # 1. Authentication
2 | curl --location --request POST 'https://api-server.compdf.com/server/v1/oauth/token' \
3 | --header 'Content-Type: application/json' \
4 | --data-raw '{
5 | "publicKey": "publicKey",
6 | "secretKey": "secretKey"
7 | }'
8 |
9 | # 2. Create Task
10 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/docx/pdf?language=1' \
11 | --header 'Authorization: Bearer accessToken'
12 |
13 | # 3. Upload File
14 | curl --location --request POST 'https://api-server.compdf.com/server/v1/file/upload' \
15 | --header 'Authorization: Bearer accessToken' \
16 | --form 'file=@"input_files/word.docx"' \
17 | --form 'taskId="taskId"' \
18 | --form 'language="1"'
19 |
20 | # 4. Execute Task
21 | curl --location --request GET 'https://api-server.compdf.com/server/v1/execute/start?taskId=taskId' \
22 | --header 'Authorization: Bearer accessToken'
23 |
24 | # 5. Get Task Information
25 | curl --location --request GET 'https://api-server.compdf.com/server/v1/task/taskInfo?taskId=taskId' \
26 | --header 'Authorization: Bearer accessToken'
27 |
--------------------------------------------------------------------------------