Skip to content

Commit 4547d6b

Browse files
updated typescript scripts
1 parent 593f2e6 commit 4547d6b

11 files changed

Lines changed: 1438 additions & 259 deletions

samples/python/README.md

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,163 @@ python convert_cli.py ../../test_files/test-batch/Analysis.docx /tmp/output.pdf
316316
./test_all.sh
317317
```
318318

319-
## Sample Files
319+
## Testing with Sample Files
320+
321+
The repository includes test files you can use to try out the scripts. All test files are located in the `../../test_files/` directory (relative to the Python samples folder).
322+
323+
### Quick Test Commands
324+
325+
#### 1. Test Authentication
326+
```bash
327+
uv run python quickstart.py
328+
# Expected: ✅ Authentication successful! Token: eyJ0...
329+
```
330+
331+
#### 2. Convert Single Document
332+
```bash
333+
# Convert Word document to PDF
334+
uv run python convert_cli.py ../../test_files/test-batch/Analysis.docx output/test_output.pdf pdf
335+
336+
# Convert Excel to PDF
337+
uv run python convert_cli.py ../../test_files/test-batch/Feedback.xlsx output/test_output.pdf pdf
338+
339+
# Convert PowerPoint to PNG
340+
uv run python convert_cli.py ../../test_files/SamplePPTX.pptx output/test_output.png png
341+
```
342+
343+
#### 3. Batch Document Conversion
344+
```bash
345+
# Convert all Word documents in test-batch to PDF
346+
uv run python batch_process.py \
347+
../../test_files/test-batch \
348+
output/batch_results \
349+
pdf \
350+
"*.docx"
351+
352+
# Convert all Excel files
353+
uv run python batch_process.py \
354+
../../test_files/test-batch \
355+
output/batch_results \
356+
pdf \
357+
"*.xlsx"
358+
```
359+
360+
#### 4. Extract Data from PDFs
361+
```bash
362+
# Extract form fields from student loan application
363+
uv run python extract_data.py \
364+
forms \
365+
"../../test_files/test-pdfs/BOB - Student-Loan-Application-Form.pdf" \
366+
output/forms_output.json
367+
368+
# Extract tables from PDF
369+
uv run python extract_data.py \
370+
tables \
371+
"../../test_files/test-pdfs/Sample Tables.pdf" \
372+
output/tables_output.json
373+
```
374+
375+
#### 5. Smart PII Redaction
376+
```bash
377+
# Automatically detect and redact PII from PDFs
378+
uv run python smart_redact_pii.py \
379+
../../test_files/test-pdfs \
380+
output/pii_redacted
381+
```
382+
383+
#### 6. Keyword-Based Redaction
384+
```bash
385+
# Redact specific keywords from resume
386+
uv run python redact_by_keyword.py \
387+
../../test_files/test-pdfs/SampleResume.pdf \
388+
output/redacted.pdf \
389+
"resume" "contact"
390+
```
391+
392+
#### 7. Bulk Password Protection
393+
```bash
394+
# Password protect all PDFs in test-pdfs folder
395+
uv run python bulk_password_protect.py \
396+
../../test_files/test-pdfs \
397+
output/protected \
398+
"SecurePass123"
399+
```
400+
401+
#### 8. Prepare PDFs for Distribution
402+
```bash
403+
# Convert marketing brochures to optimized PDFs with metadata removed
404+
uv run python prepare_pdf_for_distribution.py \
405+
../../test_files/pdf-distribution \
406+
output/distribution
407+
```
408+
409+
#### 9. Employee Policy Onboarding (Sign API)
410+
```bash
411+
# Send company policies for signature to employees
412+
uv run python employee_policy_onboarding.py \
413+
../../test_files/test-sign \
414+
../../test_files/test-sign/employees.csv
415+
416+
# Note: This sends real signature requests to email addresses in the CSV!
417+
# Check the CSV file first: ../../test_files/test-sign/employees.csv
418+
```
419+
420+
### Using Task Commands
421+
422+
All the above can also be run using Task commands for convenience:
423+
424+
```bash
425+
# Convert
426+
task convert INPUT=../../test_files/test-batch/Analysis.docx OUTPUT=output/test.pdf FORMAT=pdf
427+
428+
# Batch process
429+
task batch INPUT_DIR=../../test_files/test-batch OUTPUT_DIR=output/batch FORMAT=pdf PATTERN='*.docx'
430+
431+
# Extract data
432+
task extract MODE=tables INPUT="../../test_files/test-pdfs/Sample Tables.pdf" OUTPUT=output/tables.json
433+
434+
# Smart redact
435+
task smart-redact INPUT_DIR=../../test_files/test-pdfs OUTPUT_DIR=output/redacted
436+
437+
# Prepare PDFs
438+
task prepare-distribution INPUT_DIR=../../test_files/pdf-distribution OUTPUT_DIR=output/distribution
439+
440+
# Employee onboarding
441+
task onboard-employees POLICIES_DIR=../../test_files/test-sign CSV=../../test_files/test-sign/employees.csv
442+
```
443+
444+
### Available Test Files
320445

321446
Sample files for testing are available in the `test_files/` folder at the repository root.
322447

448+
#### Batch Conversion (`test_files/test-batch/`)
449+
- `Analysis.docx` - Word document
450+
- `Feedback.xlsx` - Excel spreadsheet
451+
452+
#### PDF Operations (`test_files/test-pdfs/`)
453+
- `SampleResume.pdf` - Resume with PII (for redaction testing)
454+
- `Sample Tables.pdf` - PDF with tables (for extraction)
455+
- `BOB - Student-Loan-Application-Form.pdf` - Form with fields (for extraction)
456+
457+
#### Distribution (`test_files/pdf-distribution/`)
458+
- `Marketing_Brochure_Product_A_Rich.docx`
459+
- `Marketing_Brochure_Product_B_Rich.docx`
460+
- `Marketing_Brochure_Product_C_Rich.docx`
461+
462+
#### Sign API (`test_files/test-sign/`)
463+
- `company-policies.pdf` - Company policy document
464+
- `confidentiality-agreement.pdf` - NDA template
465+
- `sample-company-policies.pdf` - Additional policy
466+
- `employees.csv` - Sample employee list for testing
467+
468+
### Important Notes
469+
470+
- **Sign API Testing**: The `employee_policy_onboarding` script sends real signature requests via email. Make sure the email addresses in `employees.csv` are valid and you have permission to send them test requests.
471+
- **Output Folders**: All scripts automatically create output folders if they don't exist.
472+
- **File Paths**: Use quotes around file paths with spaces (e.g., `"Sample Tables.pdf"`).
473+
- **Large Files**: Some operations may take longer with large or complex documents.
474+
475+
323476
## Getting Your Credentials
324477

325478
1. Go to [https://admin.gonitro.com](https://admin.gonitro.com)

samples/typescript/README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,111 @@ output/
258258
└── envelope-info.json
259259
```
260260

261+
## Testing with Sample Files
262+
263+
The repository includes test files you can use to try out the scripts. All test files are located in the `../../test_files/` directory (relative to the TypeScript samples folder).
264+
265+
### Quick Test Commands
266+
267+
#### 1. Test Authentication
268+
```bash
269+
npm run quickstart
270+
# Expected: ✅ Authentication successful! Token: eyJ0...
271+
```
272+
273+
#### 2. Convert Single Document
274+
```bash
275+
# Convert Word document to PDF
276+
npm run convert -- ../../test_files/test-batch/Analysis.docx output.pdf pdf
277+
278+
# Convert Excel to PDF
279+
npm run convert -- ../../test_files/test-batch/Feedback.xlsx output.pdf pdf
280+
281+
# Convert PowerPoint to PNG
282+
npm run convert -- ../../test_files/SamplePPTX.pptx output.png png
283+
```
284+
285+
#### 3. Batch Document Conversion
286+
```bash
287+
# Convert all Word documents in test-batch to PDF
288+
npm run batch -- ../../test_files/test-batch ./output pdf "*.docx"
289+
290+
# Convert all Excel files
291+
npm run batch -- ../../test_files/test-batch ./output pdf "*.xlsx"
292+
```
293+
294+
#### 4. Extract Data from PDFs
295+
```bash
296+
# Extract form fields from student loan application
297+
npm run extract -- forms "../../test_files/test-pdfs/BOB - Student-Loan-Application-Form.pdf" forms-output.json
298+
299+
# Extract tables from PDF
300+
npm run extract -- tables "../../test_files/test-pdfs/Sample Tables.pdf" tables-output.json
301+
```
302+
303+
#### 5. Smart PII Redaction
304+
```bash
305+
# Automatically detect and redact PII from resume
306+
npm run smart-redact -- ../../test_files/test-pdfs ./redacted-output
307+
```
308+
309+
#### 6. Keyword-Based Redaction
310+
```bash
311+
# Redact specific keywords from resume
312+
npm run redact-keyword -- ../../test_files/test-pdfs/SampleResume.pdf redacted.pdf "resume" "contact"
313+
```
314+
315+
#### 7. Bulk Password Protection
316+
```bash
317+
# Password protect all PDFs in test-pdfs folder
318+
npm run bulk-password -- ../../test_files/test-pdfs ./protected-output "SecurePass123"
319+
```
320+
321+
#### 8. Prepare PDFs for Distribution
322+
```bash
323+
# Convert marketing brochures to optimized PDFs with metadata removed
324+
npm run prepare-pdf -- ../../test_files/pdf-distribution ./distribution-output
325+
```
326+
327+
#### 9. Employee Policy Onboarding (Sign API)
328+
```bash
329+
# Send company policies for signature to employees
330+
npm run employee-policy -- ../../test_files/test-sign ../../test_files/test-sign/employees.csv
331+
332+
# Note: This sends real signature requests to email addresses in the CSV!
333+
# Check the CSV file first: ../../test_files/test-sign/employees.csv
334+
```
335+
336+
### Available Test Files
337+
338+
#### Batch Conversion (`test_files/test-batch/`)
339+
- `Analysis.docx` - Word document
340+
- `Feedback.xlsx` - Excel spreadsheet
341+
342+
#### PDF Operations (`test_files/test-pdfs/`)
343+
- `SampleResume.pdf` - Resume with PII (for redaction testing)
344+
- `Sample Tables.pdf` - PDF with tables (for extraction)
345+
- `BOB - Student-Loan-Application-Form.pdf` - Form with fields (for extraction)
346+
347+
#### Distribution (`test_files/pdf-distribution/`)
348+
- `Marketing_Brochure_Product_A_Rich.docx`
349+
- `Marketing_Brochure_Product_B_Rich.docx`
350+
- `Marketing_Brochure_Product_C_Rich.docx`
351+
352+
#### Sign API (`test_files/test-sign/`)
353+
- `company-policies.pdf` - Company policy document
354+
- `confidentiality-agreement.pdf` - NDA template
355+
- `sample-company-policies.pdf` - Additional policy
356+
- `employees.csv` - Sample employee list for testing
357+
358+
359+
### Important Notes
360+
361+
- **Sign API Testing**: The `employee-policy-onboarding` script sends real signature requests via email. Make sure the email addresses in `employees.csv` are valid and you have permission to send them test requests.
362+
- **Output Folders**: All scripts automatically create output folders if they don't exist.
363+
- **File Paths**: Use quotes around file paths with spaces (e.g., `"Sample Tables.pdf"`).
364+
- **Large Files**: Some operations may take longer with large or complex documents.
365+
261366
## Code Style & Conventions
262367

263368
### Naming Conventions

0 commit comments

Comments
 (0)