Document Processing

Convert between document formats: PDF, HTML, Markdown, and Excel. Automate report generation and document workflows.

Quick Reference: All requests go to POST /api/services/execute with your API key in the Authorization: Bearer YOUR_API_KEY header.


Generate PDF Reports from HTML

Service: html-to-pdf

Convert HTML templates to professional PDF documents. Perfect for invoices, reports, certificates, and any printable content.

Generate an Invoice PDF

Create a downloadable invoice from your billing data.

// JavaScript - Generate invoice PDF
const invoiceHtml = `
  <html>
  <head><style>
    body { font-family: Arial, sans-serif; padding: 40px; }
    .header { display: flex; justify-content: space-between; margin-bottom: 40px; }
    .invoice-number { font-size: 24px; font-weight: bold; }
    table { width: 100%; border-collapse: collapse; margin: 20px 0; }
    th, td { border: 1px solid #ddd; padding: 12px; text-align: left; }
    th { background: #f5f5f5; }
    .total { font-size: 20px; font-weight: bold; text-align: right; margin-top: 20px; }
  </style></head>
  <body>
    <div class="header">
      <div><h1>ACME Corp</h1><p>123 Business St</p></div>
      <div class="invoice-number">Invoice #2024-0892</div>
    </div>
    <table>
      <tr><th>Description</th><th>Qty</th><th>Price</th><th>Total</th></tr>
      <tr><td>Web Design Services</td><td>1</td><td>$500.00</td><td>$500.00</td></tr>
      <tr><td>Logo Design</td><td>1</td><td>$150.00</td><td>$150.00</td></tr>
    </table>
    <div class="total">Total: $650.00</div>
  </body>
  </html>
`;

const response = await fetch('https://www.acrewity.com/api/services/execute', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    service: 'html-to-pdf',
    operation: 'convert_pdf',
    parameters: {
      html: invoiceHtml,
      format: 'A4',
      margin: { top: '20mm', bottom: '20mm', left: '15mm', right: '15mm' }
    }
  })
});

const { result } = await response.json();
// result.data.pdf contains base64-encoded PDF

Use Cases:

Automated Reports

Generate weekly/monthly PDF reports from your dashboard data automatically.

Certificates & Diplomas

Create personalized certificates for course completions or achievements.

Contracts & Agreements

Generate legal documents from templates with customer-specific details.

Shipping Labels

Create printable shipping labels with barcodes and address information.


Extract Data from PDFs

Services: pdf-to-markdown, pdf-to-html

Extract text and structure from PDF documents. Use for document ingestion, search indexing, or content migration.

Extract Text from an Uploaded Contract

Process a user-uploaded PDF to extract its content for analysis.

# Python - Extract PDF content
import requests
import base64

# Read the PDF file
with open('contract.pdf', 'rb') as f:
    pdf_base64 = base64.b64encode(f.read()).decode()

response = requests.post(
    'https://www.acrewity.com/api/services/execute',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'service': 'pdf-to-markdown',
        'operation': 'convert',
        'parameters': {
            'file': pdf_base64
        }
    }
)

result = response.json()
markdown_content = result['result']['data']['markdown']
page_count = result['result']['data']['pageCount']

print(f"Extracted {page_count} pages")
print(markdown_content)

Use Cases:

Document Search

Extract PDF text to build searchable document indexes for your application.

AI Document Analysis

Convert PDFs to text for processing with LLMs for summarization or Q&A.


PDF Page Manipulation

Services: pdf-merge, pdf-extract-page

Combine multiple PDFs into one, or extract specific pages. Essential for document assembly workflows.

Merge Contract with Signature Page

Combine the main contract PDF with a separately signed signature page.

// JavaScript - Merge two PDFs
const contractPdf = await readFileAsBase64('contract.pdf');
const signaturePdf = await readFileAsBase64('signature-page.pdf');

const response = await fetch('https://www.acrewity.com/api/services/execute', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    service: 'pdf-merge',
    operation: 'merge',
    parameters: {
      source_pdf: contractPdf,
      target_pdf: signaturePdf
    }
  })
});

const { result } = await response.json();
// result.data.pdf contains the merged PDF

Extract Cover Page from a Report

Pull out just the first page for a thumbnail or preview.

curl -X POST https://www.acrewity.com/api/services/execute \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "service": "pdf-extract-page",
    "operation": "extract",
    "parameters": {
      "pdf": "BASE64_ENCODED_PDF",
      "page_numbers": [1]
    }
  }'

Related Services