Metadata-Version: 2.4
Name: draggit-sdk
Version: 2.0.0
Summary: Professional PDF watermarking service SDK
Home-page: https://github.com/sagarsethi11020-lab/draggit-sdk
Author: Draggit Team
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Office/Business
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28.0
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Draggit SDK

Professional PDF watermarking service for Python applications.

## Features

✅ **Easy Integration** - Simple Python API
✅ **Free/Paid Tiers** - Free keys get a watermarked PDF, paid keys get a clean one - no code change needed to switch, just swap your `api_key`
✅ **License Tracking** - Built-in usage monitoring
✅ **Secure** - API key authentication
✅ **Black Box** - No code modification possible

## Installation

```bash
pip install draggit-sdk
```

## Quick Start

```python
from draggit import DraggitClient

# Initialize client
client = DraggitClient(api_key="your-api-key")

# Watermark PDF (see "DSC Digital Signatures" below before you apply
# your own certificate signature - order matters!)
result = client.sign_and_save(
    input_pdf="document.pdf",
    output_pdf="document_signed.pdf"
)

print(f"Signed! Used {result['signatures_used']} signatures")
```

> **Naming note:** despite the method name, `sign_and_save()` only adds the
> Draggit watermark/logo - it never performs cryptographic signing or touches
> a certificate/private key. See [DSC Digital Signatures](#dsc-digital-signatures) below.

## Usage

### Basic Signing

```python
client = DraggitClient(api_key="demo-key")

# Sign and save
result = client.sign_and_save("input.pdf", "output.pdf")
# Returns: {
#   'status': 'success',
#   'message': 'PDF signed successfully with Draggit watermarks',
#   'tier': 'free',
#   'signatures_used': 1,
#   'output_file': 'output.pdf',
#   'file_size': 28136
# }
```

### Check License

```python
# Validate API key
is_valid, info = client.validate_license()

if is_valid:
    print(f"Valid! Remaining: {info['signatures_remaining']}")
else:
    print("Invalid or expired API key")

# Get detailed info
license_info = client.get_license_info()
print(f"Tier: {license_info['license_type']}")
print(f"Used: {license_info['signatures_used']}/{license_info['signatures_limit']}")
```

## DSC Digital Signatures

Draggit **never** touches your certificate, private key, or performs
cryptographic signing - that always happens with your own DSC tool (USB
token, emSigner, Aadhaar eSign, etc.). Draggit only prepares the PDF's
visible watermark and logo.

**Correct order: watermark first, sign last.**

```
1. You have a raw, UNSIGNED PDF
2. client.sign_and_save(raw_pdf, watermarked_pdf)   <- Draggit step
3. You sign `watermarked_pdf` with your own DSC tool <- your step, LAST
4. Final PDF: watermarked AND validly signed
```

This order matters because a digital signature is a cryptographic hash of
the exact file bytes at signing time. If you watermark a PDF *after* it's
already signed, the signature becomes invalid ("document modified after
signing") in any PDF viewer. Always send Draggit the unsigned PDF, and sign
the watermarked output it returns - never the other way around.

**The signature field follows automatically, on every tier.** If your PDF
already has a signature field (from a form template or your DSC tool),
Draggit's output keeps a field in exactly that box on that page. If it
doesn't, Draggit creates an empty signature field placeholder at a default
position - so your DSC tool will find a real field to sign into either way,
without you needing to pass any coordinates. On the free tier, a "Draggit
Signed" logo is also drawn there; on a paid key, the field is created but
nothing is drawn on top of it.

## API Keys

- `demo-key` - free tier, 100 signatures, watermarked output.
- Paid keys are issued individually per customer and return watermark-free
  output - contact support@draggit.com to get one. Swapping `api_key` is the
  only code change needed to go from watermarked to clean.

> **First request may be slow:** the hosted API runs on a free-tier instance
> that spins down after inactivity. If it's been idle, `DraggitClient(...)`
> can take up to ~60 seconds to connect while it wakes back up - this is
> normal, not an error. Subsequent requests are fast until it goes idle again.

## Error Handling

```python
from draggit import DraggitClient

try:
    client = DraggitClient(api_key="invalid-key")
except ConnectionError as e:
    print(f"Connection error: {e}")

try:
    result = client.sign_and_save("nonexistent.pdf", "output.pdf")
except FileNotFoundError as e:
    print(f"File error: {e}")
except ValueError as e:
    print(f"API error: {e}")
```

## What This SDK Does

✅ Adds a "draggit" watermark + logo signature to free-tier PDFs; removes both for a paid key
✅ Detects (or creates) a signature field so your DSC tool has somewhere to sign, on every tier
✅ License-based usage tracking
✅ Simple Python API

## What This SDK Does NOT Do

❌ Cryptographic DSC signing with a certificate/private key - that's always done with **your own** DSC tool, and always **after** calling Draggit (see [DSC Digital Signatures](#dsc-digital-signatures))
❌ Code modification (black box - no source code access)
❌ Decompilation possible

## Support

For support, contact: support@draggit.com

## License

Proprietary - See LICENSE file
