### Install Documind via npm Source: https://github.com/documindhq/documind/blob/main/README.md Installs the Documind package using npm. Ensure Node.js (v18+) and npm are installed on your system before running this command. ```bash npm install documind ``` -------------------------------- ### Install System Dependencies Source: https://github.com/documindhq/documind/blob/main/README.md Installs Ghostscript and GraphicsMagick, which are required for PDF operations and image processing in Documind. Instructions are provided for macOS and Debian/Ubuntu. ```bash # On macOS brew install ghostscript graphicsmagick # On Debian/Ubuntu sudo apt-get update sudo apt-get install -y ghostscript graphicsmagick ``` -------------------------------- ### Example JSON Output Structure Source: https://github.com/documindhq/documind/blob/main/README.md This JSON structure represents an example of extracted data, likely from a bank statement. It includes account details, transaction history with debit and credit amounts, and balances. This format is useful for structured data processing. ```json { "success": true, "pages": 1, "data": { "accountNumber": "100002345", "openingBalance": 3200, "transactions": [ { "date": "2021-05-12", "creditAmount": null, "debitAmount": 100, "description": "transfer to Tom" }, { "date": "2021-05-12", "creditAmount": 50, "debitAmount": null, "description": "For lunch the other day" }, { "date": "2021-05-13", "creditAmount": 20, "debitAmount": null, "description": "Refund for voucher" }, { "date": "2021-05-13", "creditAmount": null, "debitAmount": 750, "description": "May's rent" } ], "closingBalance": 2420 }, "fileName": "bank_statement.pdf" } ``` -------------------------------- ### Extract Data Using a Documind Template Source: https://github.com/documindhq/documind/blob/main/README.md This JavaScript example shows how to use the `extract` function from the 'documind' library to process a PDF file ('https://bank_statement.pdf') using a specific template ('bank_statement'). The extracted data is then logged to the console. It requires an asynchronous function to handle the extraction process. ```javascript import { extract } from 'documind'; const runExtraction = async () => { const result = await extract({ file: 'https://bank_statement.pdf', template: 'bank_statement' }); console.log("Extracted Data:", result); }; runExtraction(); ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/documindhq/documind/blob/main/README.md Sets up the .env file to store sensitive information, such as the OpenAI API key, which is required for Documind to function. ```bash OPENAI_API_KEY=your_openai_api_key ``` -------------------------------- ### List Available Documind Templates Source: https://github.com/documindhq/documind/blob/main/README.md This JavaScript code snippet demonstrates how to import and use the `templates.list` function from the 'documind' library to retrieve a list of all available document extraction templates. The output is logged to the console. ```javascript import { templates } from 'documind'; const templates = templates.list(); console.log(templates); // Logs all available template names ``` -------------------------------- ### Run Documind Extraction Source: https://github.com/documindhq/documind/blob/main/README.md Imports the 'extract' function from the 'documind' library and uses it to process a PDF file. It takes the file URL and the defined schema as arguments and logs the extracted data. ```javascript import { extract } from 'documind'; const runExtraction = async () => { const result = await extract({ file: 'https://bank_statement.pdf', schema }); console.log("Extracted Data:", result); }; runExtraction(); ``` -------------------------------- ### Define a Schema for Bank Statement Extraction Source: https://github.com/documindhq/documind/blob/main/README.md Defines a JSON schema for extracting structured data from a bank statement. The schema includes fields like accountNumber, openingBalance, transactions (with nested fields), and closingBalance. ```javascript const schema = [ { name: "accountNumber", type: "string", description: "The account number of the bank statement." }, { name: "openingBalance", type: "number", description: "The opening balance of the account." }, { name: "transactions", type: "array", description: "List of transactions in the account.", children: [ { name: "date", type: "string", description: "Transaction date." }, { name: "creditAmount", type: "number", description: "Credit Amount of the transaction." }, { name: "debitAmount", type: "number", description: "Debit Amount of the transaction." }, { name: "description", type: "string", description: "Transaction description." } ] }, { name: "closingBalance", type: "number", description: "The closing balance of the account." } ]; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.