Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/compdfkit/compdfkit-api-python
A Python component library for integrating with ComPDFKit API to build a PDF Viewer and Editor.
https://github.com/compdfkit/compdfkit-api-python
api compdfkit-api pdf pdf-converter pdf-document pdf-editor pdf-viewer python
Last synced: 4 days ago
JSON representation
A Python component library for integrating with ComPDFKit API to build a PDF Viewer and Editor.
- Host: GitHub
- URL: https://github.com/compdfkit/compdfkit-api-python
- Owner: ComPDFKit
- License: mit
- Created: 2023-09-07T02:26:55.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-01T02:30:34.000Z (4 months ago)
- Last Synced: 2024-08-01T10:46:16.967Z (4 months ago)
- Topics: api, compdfkit-api, pdf, pdf-converter, pdf-document, pdf-editor, pdf-viewer, python
- Language: Python
- Homepage: https://api.compdf.com
- Size: 34.2 KB
- Stars: 19
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## ComPDFKit API in Python
[ComPDFKit](https://api.compdf.com/api/docs/introduction) API provides a variety of Python API tools that allow you to create an efficient document processing workflow in a single API call. Try our various APIs for free — no credit card required.
## Requirements
Programming Environment: Python 3.8 and higher.
Dependencies: pip.
## Installation
You can install the library via pip. Run the following command:
```shell script
pip install compdfkit-api-python
```## Create API Client
You can use your **publicKey** and **secretKey** to complete the authentication. You need to [sign in](https://api.compdf.com/login) your ComPDFKit API account to get your **publicKey** and **secretKey** at the [dashboard](https://api-dashboard.compdf.com/api/keys). If you are new to ComPDFKit, click here to [sign up](https://api.compdf.com/signup) for a free trial.
- Project public Key: You can find the public key in the **API Keys** section of your ComPDFKit API account.
- Project secret Key: You can find the secret key in the **API Keys** section of your ComPDFKit API account.
```python
# Create a client
client = CPDFClient(public_key, secret_key)
```## Create Task
A task ID is automatically generated for you based on the type of PDF tool you choose. You can provide the callback notification URL. After the task processing is completed, we will notify you of the task result through the callback interface. You can perform other operations according to the request result, such as checking the status of the task, uploading files, starting the task, or downloading the result file.
```python
# Create a client
client = CPDFClient(public_key, secret_key)# Create a task
# Create an example task to convert a PDF tO a Word
create_task_result = client.create_task(CPDFConversionEnum.PDF_TO_WORD)# Get a task id
task_id = create_task_result.task_id
```## Upload Files
Upload the original file and bind the file to the task ID. The field parameter is used to pass the JSON string to set the processing parameters for the file. Each file will generate automatically a unique file key. Please note that a maximum of five files can be uploaded for a task ID and no files can be uploaded for that task after it has started.
```python
# Create a client
client = CPDFClient(public_key, secret_key)# Create a task
# Create an example task to convert a PDF tO a Word
create_task_result = client.create_task(CPDFConversionEnum.PDF_TO_WORD)# Get a task id
task_id = create_task_result.task_id# Upload files
client.upload_file(convert_file, task_id)
```## Execute the Task
After the file upload is completed, call this interface with the task ID to process the files.
```python
# Create a client
client = CPDFClient(public_key, secret_key)# Create a task
# Create an example task to convert a PDF tO a Word
create_task_result = client.create_task(CPDFConversionEnum.PDF_TO_WORD)# Get a task id
task_id = create_task_result.task_id# Upload files
client.upload_file(convert_file, task_id)# execute Task
client.execute_task(task_id)
```## Get Task Info
Request task status and file-related meta data based on the task ID.
```python
# Create a client
client = CPDFClient(public_key, secret_key)# Create a task
# Create an example task to convert a PDF tO a Word
create_task_result = client.create_task(CPDFConversionEnum.PDF_TO_WORD)# Get a task id
task_id = create_task_result.task_id# Upload files
client.upload_file(convert_file, task_id)# execute task
client.execute_task(task_id)# Query TaskInfo
task_info = client.get_task_info(task_id)
```## Samples
See ***"Samples"*** folder in this folder.
## Resources
- [ComPDFKit API Libraries](https://api.compdf.com/api-libraries/overview)
- [ComPDFKit API Documentation](https://api.compdf.com/api/docs/introduction)