REST API to download, digitally stamp, encrypt and return PDF documents
/api/dscsign
Sign a PDF — returns Base64 JSON
Downloads the PDF from the given URL, appends a full DSC stamp page, encrypts the result (AES-128, print-only), and returns the signed PDF as a Base64-encoded string in JSON.
{
"pdfUrl": "https://your-server.com/documents/invoice.pdf", // required — must be publicly accessible
"purpose": "Invoice Authorisation", // required — reason shown on stamp
"signerName": "Arpit Shukla", // optional — defaults to "Arpit Shukla"
"signerOrg": "Marmelos Technologies Pvt. Ltd.", // optional
"location": "Lucknow, Uttar Pradesh" // optional
}
{
"success": true,
"message": "DSC stamp applied and PDF encrypted successfully.",
"pdfBase64": "JVBERi0xLjQK...", // Base64-encoded signed+encrypted PDF bytes
"fileName": "DSC_Signed_20260419_143022.pdf",
"signedAt": "2026.04.19 14:30:22 +05'30'",
"signer": "Arpit Shukla, Marmelos Technologies Pvt. Ltd.",
"purpose": "Invoice Authorisation",
"fileSizeBytes": 148320
}
| Status | When | Message field |
|---|---|---|
| 400 | Missing required fields | Validation error list |
| 400 | URL download fails | Failed to download PDF: … |
| 400 | URL returns non-PDF content | The URL did not return a valid PDF. |
| 500 | Internal processing error | Internal error: … |
const response = await fetch('/api/dscsign', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
pdfUrl: 'https://your-server.com/invoice.pdf',
purpose: 'Invoice Authorisation'
})
});
const data = await response.json();
if (data.success) {
// Decode and download
const bytes = Uint8Array.from(atob(data.pdfBase64), c => c.charCodeAt(0));
const blob = new Blob([bytes], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = data.fileName;
a.click();
}
using var http = new HttpClient();
var payload = new {
pdfUrl = "https://your-server.com/invoice.pdf",
purpose = "Invoice Authorisation"
};
var resp = await http.PostAsJsonAsync("/api/dscsign", payload);
var data = await resp.Content.ReadFromJsonAsync<dynamic>();
if ((bool)data.success) {
byte[] pdf = Convert.FromBase64String((string)data.pdfBase64);
File.WriteAllBytes(data.fileName, pdf);
}
import requests, base64
r = requests.post('http://localhost:5000/api/dscsign', json={
'pdfUrl': 'https://your-server.com/invoice.pdf',
'purpose': 'Invoice Authorisation'
})
data = r.json()
if data['success']:
pdf = base64.b64decode(data['pdfBase64'])
with open(data['fileName'], 'wb') as f:
f.write(pdf)
curl -X POST http://localhost:5000/api/dscsign \
-H "Content-Type: application/json" \
-d '{
"pdfUrl": "https://your-server.com/invoice.pdf",
"purpose": "Invoice Authorisation"
}' | python -c "
import sys, json, base64
d = json.load(sys.stdin)
if d['success']:
open(d['fileName'], 'wb').write(base64.b64decode(d['pdfBase64']))
print('Saved:', d['fileName'])
"
/api/dscsign/download
Direct file download
Same as POST but returns the signed PDF directly as a file download — useful for browser links and integration with download managers.
| Parameter | Required | Default | Description |
|---|---|---|---|
url | Yes | — | URL of the source PDF |
purpose | No | Document Authorisation | Reason shown on DSC stamp |
signerName | No | Arpit Shukla | Signer display name |
location | No | Lucknow, Uttar Pradesh | Location on stamp |
GET /api/dscsign/download?url=https://example.com/doc.pdf&purpose=Invoice+Authorisation
/api/dscsign/logs
Usage history (JSON)
| Parameter | Default | Description |
|---|---|---|
page | 1 | Page number |
size | 50 | Records per page |
{
"total": 42,
"page": 1,
"size": 50,
"items": [
{
"id": 1, "pdfUrl": "https://…/invoice.pdf",
"purpose": "Invoice Authorisation", "signerName": "Arpit Shukla",
"success": true, "errorMsg": null,
"fileSizeBytes": 148320, "callerIp": "192.168.1.5",
"signedAt": "2026-04-19T14:30:22"
}
]
}
| Endpoints | |
|---|---|
| POST | /api/dscsign |
| GET | /api/dscsign/download |
| GET | /api/dscsign/logs |
| Security | |
| AES-128 encrypted output Print-only permissions Edit/copy blocked | |
| Stamp Contents | |
| ✔ Signature Valid badge Signer name & org IST timestamp Location & purpose Company seal image | |
| # | Signed At (IST) | PDF URL | Purpose | Signer | Status | Size | Caller IP |
|---|---|---|---|---|---|---|---|
| Loading history… | |||||||