Skip to content

Commit fdb5bb2

Browse files
PIGS-74_Updated storytelling of samples (#5)
1 parent 2c2970e commit fdb5bb2

File tree

10 files changed

+141
-97
lines changed

10 files changed

+141
-97
lines changed

samples/python/api/base_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from pydantic import BaseModel, Field
1111
from pydantic_settings import BaseSettings, SettingsConfigDict
1212

13-
1413
TOKEN_EXPIRY_BUFFER_SECONDS = 60
1514

1615

samples/python/api/platform_api.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def _request(
3838
data = {"method": method, "params": json.dumps(params or {})}
3939

4040
response = self._client.post(
41-
f"{self._settings.platform_base_url}/{endpoint}", headers=headers, files=files, data=data
41+
f"{self._settings.platform_base_url}/{endpoint}",
42+
headers=headers,
43+
files=files,
44+
data=data,
4245
)
4346

4447
response.raise_for_status()
@@ -62,7 +65,10 @@ def _request_bytes(
6265
data = {"method": method, "params": json.dumps(params or {})}
6366

6467
response = self._client.post(
65-
f"{self._settings.platform_base_url}/{endpoint}", headers=headers, files=files, data=data
68+
f"{self._settings.platform_base_url}/{endpoint}",
69+
headers=headers,
70+
files=files,
71+
data=data,
6672
)
6773

6874
response.raise_for_status()

samples/python/batch_process.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
📁 BATCH DOCUMENT CONVERSION
44
=============================
55
6-
The script exemplifies a typical workflow for document format standardization.
7-
As a IT administrator, it's essential to convert
8-
large collections of documents into standardized formats for archival, compliance,
9-
or system integration purposes. Manually converting individual files through desktop
10-
applications is time-consuming and impractical for large document sets, often leading
11-
to inconsistent results and wasted effort.
12-
13-
This workflow automates bulk document conversion. The script processes files
14-
individually - for every document matching the specified pattern in the input folder,
15-
it converts the file to the target format (PDF, DOCX, XLSX, PNG, JPG, etc.) using
16-
high-fidelity conversion algorithms. Each converted file is saved to the output
17-
folder with the same base name but the new format extension, resulting in a
18-
complete batch of standardized documents.
6+
This script shows a standard workflow for document format standardization.
7+
8+
As an IT administrator, you must convert many documents to standard
9+
formats for archiving, compliance, or system integration. Manual conversion
10+
with desktop applications takes a long time and is not practical for large
11+
document sets. It can also cause inconsistent results and wasted effort.
12+
13+
This workflow automates bulk document conversion. The script scans the input
14+
folder for files that match a specified pattern and processes each file one
15+
by one. For each document, the script converts the file to the target format,
16+
such as PDF, DOCX, XLSX, PNG, or JPG, using high-quality conversion methods.
17+
18+
Each converted file is saved in the output folder with the same base name and a new
19+
format extension. The result is a complete set of standardized documents that are
20+
ready for use.
1921
2022
BATCH CONVERSION FEATURES:
2123
✓ Multiple format support (PDF, DOCX, XLSX, PNG, JPG, etc.)
@@ -38,6 +40,7 @@
3840
from api.platform_api import PlatformAPIClient
3941
from helper_functions.document_helpers import validate_and_setup
4042

43+
4144
class OutputFormat(str, Enum):
4245
"""Supported output formats for document conversion."""
4346

samples/python/bulk_password_protect.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@
33
🔐 BULK PASSWORD PROTECTION
44
============================
55
6-
The script exemplifies a typical workflow for securing confidential documents.
7-
As a security professional, it's essential to protect sensitive
8-
documents with passwords before distributing them to authorized personnel, storing
9-
them in shared drives, or archiving them for compliance purposes. Manually setting
10-
passwords on individual files is tedious and inconsistent, leading to weak passwords
11-
or missed files that remain unprotected.
12-
13-
This workflow automates secure document protection. The script processes each PDF
14-
file individually - for every document in the input folder, it applies robust
15-
password encryption using a consistent password across all files. Each protected
16-
file is saved to the output folder with the same filename, ensuring that the entire
17-
batch of documents maintains uniform security standards. The result is a complete
18-
set of password-protected PDFs ready for secure distribution or storage.
6+
This script shows a standard workflow to protect confidential documents.
7+
8+
Security staff must protect sensitive documents with passwords before they
9+
share them with authorized users, save them in shared drives, or store them
10+
for compliance. Manually adding passwords to individual files takes a lot of
11+
time and can cause errors. This can result in weak passwords or files that are
12+
not protected. This workflow automates document protection.
13+
14+
The script processes one PDF file at a time. For each PDF file in the input folder, the script:
15+
16+
Applies password encryption
17+
18+
Uses the same password for all files
19+
20+
Saves the protected file to the output folder with the same file
21+
name
22+
23+
This process ensures that all documents follow the same security standard.
24+
The result is a set of password-protected PDF files ready for secure
25+
sharing or storage.
1926
2027
DOCUMENT SECURITY STANDARDS:
2128
✓ Password encryption (AES-256)

samples/python/convert_cli.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
🔄 SINGLE DOCUMENT CONVERSION
44
==============================
55
6-
The script exemplifies a typical workflow for quick document format conversion.
7-
As a business professional, you often need to convert individual
8-
documents between formats for sharing, presentations, or compatibility requirements.
9-
Whether converting a Word document to PDF for distribution, an Excel spreadsheet to
10-
CSV for data processing, or a presentation to images for web display, manual
11-
conversion through multiple applications is inefficient.
12-
13-
This workflow provides instant document conversion. The script takes a single input
14-
file and converts it to the specified output format using professional-grade
15-
conversion algorithms. The result is a high-quality converted file that preserves
16-
formatting, structure, and content fidelity, ready for immediate use.
6+
This script demonstrates a simple and efficient way to convert documents between formats.
7+
8+
In daily work, you may need to convert individual files for sharing,
9+
presenting, or ensuring compatibility with different systems. For example,
10+
you might convert a Word document to a PDF for easy distribution, an Excel
11+
spreadsheet to a CSV file for data processing, or a presentation into images
12+
for use on a website. Doing this manually across multiple applications can be
13+
time-consuming and inconvenient.
14+
15+
This workflow simplifies the process by providing instant document
16+
conversion. You supply a single input file and choose the desired output
17+
format. The script handles the conversion automatically using high-quality
18+
conversion methods.
19+
20+
The resulting file maintains the original layout, structure, and content
21+
accuracy, so it is ready to use right away.
1722
1823
CONVERSION FEATURES:
1924
✓ Multiple format support (PDF, DOCX, XLSX, PNG, etc.)
@@ -36,6 +41,7 @@
3641

3742
from api.platform_api import PlatformAPIClient
3843

44+
3945
class OutputFormat(str, Enum):
4046
"""Supported output formats for document conversion."""
4147

samples/python/employee_policy_onboarding.py

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,33 @@
33
📝 EMPLOYEE POLICY ONBOARDING
44
==============================
55
6-
This script exemplifies a typical HR onboarding workflow for new employees.
7-
As an HR professional, it's necessary to ensure all new hires review and sign
8-
required company policies before their start date. Manual distribution and
9-
tracking of signatures is time-consuming and error-prone, especially when
10-
onboarding multiple employees simultaneously.
11-
12-
This workflow automates policy distribution and signature collection. The script
13-
processes each new employee individually - for every person in the CSV file, it
14-
creates a signature envelope containing all company policy documents, sends it
15-
via email with signature fields pre-configured, monitors the signing status, and
16-
automatically downloads the signed documents once completed. Each employee's
17-
signed policies are organized in their own folder, creating an audit-ready
18-
archive of onboarding documentation.
19-
20-
21-
NOTE: To run this script and see the complete workflow, you must provide a CSV file
22-
with valid employee names and email addresses. The script will send actual signature
23-
requests to these email addresses and wait for them to be signed.
6+
HR staff must make sure that all new employees review and sign required
7+
company policies before their start date. Manual distribution and manual
8+
tracking of signed documents takes a lot of time and can cause errors. This
9+
is especially true when you onboard many employees at the same time.
10+
11+
This workflow automates the distribution of policies and the collection of signatures.
12+
13+
The script processes one employee at a time. For each employee listed in the CSV file, the script:
14+
15+
Creates a signature envelope that contains all required company policy documents
16+
17+
Sends the envelope by email with signature fields already set
18+
19+
Tracks the signature status
20+
21+
Downloads the signed documents when the signing process is complete
22+
23+
The script saves each employee's signed documents in a separate folder.
24+
This creates an organized and audit-ready record of onboarding
25+
documents.
26+
27+
28+
NOTE: To run this script and view the full workflow, you must provide a
29+
CSV file with valid employee names and email addresses. The script sends
30+
real signature requests to these email addresses and waits for the
31+
employees to sign the documents.
32+
2433
2534
EMPLOYEE CSV FORMAT:
2635
name,email

samples/python/extract_data.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
📊 DOCUMENT DATA EXTRACTION
44
============================
55
6-
The script exemplifies a typical workflow for intelligent document data extraction.
7-
As a data analyst, you need to extract structured
8-
data from PDF documents - whether form fields from applications, surveys, and
9-
questionnaires, or table data from reports, invoices, and financial statements.
10-
Manual data entry is error-prone and time-consuming, especially when processing
11-
hundreds of documents for analysis or database import.
12-
13-
This workflow automates data extraction using AI-powered document understanding.
14-
The script analyzes PDF documents and intelligently identifies and extracts either
15-
form fields (with field names and values) or table structures (with rows, columns,
16-
and cell contents). The extracted data is saved as structured JSON, ready for
17-
immediate integration with databases, spreadsheets, or analytics pipelines.
6+
This script shows how to automatically extract useful data from PDF documents.
7+
8+
If you work with PDFs, you often need to pull structured information from
9+
them. This might include form fields from applications, surveys, or
10+
questionnaires, as well as table data from reports, invoices, or financial
11+
statements. Entering this information by hand can be slow and can lead to
12+
mistakes, especially when you are processing a large number of documents.
13+
14+
This workflow makes the process faster and easier by automating data
15+
extraction. The script analyzes PDF files and uses intelligent document
16+
analysis to find and extract the information you need. It can capture form
17+
fields with their names and values, or detect tables and extract their rows,
18+
columns, and cell contents.
19+
20+
The extracted data is saved in a structured JSON format. This makes it
21+
easy to load into databases, spreadsheets, or analytics tools so you can
22+
start working with the data right away.
1823
1924
DATA EXTRACTION FEATURES:
2025
✓ AI-powered form field extraction

samples/python/helper_functions/sign_helpers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from pathlib import Path
1313
from typing import TYPE_CHECKING, Any
1414

15-
import httpx
16-
1715
if TYPE_CHECKING:
1816
from api.sign_api import SignAPIClient
1917

samples/python/prepare_pdf_for_distribution.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,25 @@
33
🔒 PREPARE PDF FOR DISTRIBUTION
44
================================
55
6-
The script exemplifies a typical workflow of marketing brochure distribution.
7-
As a marketing professional, it's necessary to share company brochures externally
8-
while ensuring they comply with corporate distribution standards. Word document
9-
properties can expose internal information such as author names, template paths,
10-
revision history, and company file structures that should remain confidential.
11-
12-
This workflow automates compliant document preparation. The script processes each
13-
file individually - for every brochure in the input folder, it converts the Word
14-
document into PDF format, then compresses the file to reduce size and optimize
15-
transmission, and finally removes all metadata properties to ensure privacy and
16-
confidentiality. Each processed file is saved to the output folder, resulting in
17-
distribution-ready brochures.
6+
This script shows a standard workflow for distributing marketing brochures.
7+
As a marketing professional, it's necessary to share company brochures
8+
externally while ensuring they comply with corporate distribution standards.
9+
Word document properties can expose internal information such as author names,
10+
template paths, revision history, and company file structures that should
11+
remain confidential.
12+
13+
This workflow prepares documents for compliant distribution. The script
14+
processes each file separately. For each brochure in the input folder,
15+
the script performs these steps:
16+
17+
1. Convert the Word document to PDF format.
18+
19+
2. Compress the PDF file to reduce file size and improve transmission.
20+
21+
3. Remove all metadata to protect privacy and confidentiality.
22+
23+
The script saves each processed file to the output folder. The result is
24+
a set of brochures that are ready for external distribution.
1825
1926
COMPANY DISTRIBUTION STANDARDS:
2027
✓ PDF format (prevents editing)

samples/python/redact_by_keyword.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
🔍 KEYWORD-BASED REDACTION
44
===========================
55
6-
The script exemplifies a typical workflow for targeted content redaction.
7-
As a compliance officer, you need to redact specific
8-
sensitive terms from documents before external sharing or public disclosure.
9-
Whether removing client names, project codenames, financial figures, or
10-
proprietary terminology, manually searching through pages and applying redactions
11-
is tedious and risks missing instances, potentially exposing confidential information.
12-
13-
This workflow automates keyword-based redaction. The script searches the entire
14-
PDF document for all specified keywords and phrases, identifies their exact
15-
locations across all pages, then automatically applies permanent redactions to
16-
remove them. Multiple keywords can be processed in a single pass, ensuring
17-
comprehensive coverage. The result is a thoroughly redacted document ready for
18-
safe distribution.
6+
This script shows a standard workflow for targeted content redaction.
7+
8+
As a compliance officer, you must remove sensitive information from
9+
documents before you share them outside the organization or release them to
10+
the public. This information can include client names, project code names,
11+
financial values, or proprietary terms. Finding and removing this content
12+
by hand can be slow and difficult. You can also miss some instances, which
13+
can expose confidential information.
14+
15+
This workflow automates keyword-based redaction. The script searches the
16+
full PDF document for all specified keywords and phrases. It finds each
17+
instance on every page. The script then applies permanent redactions to
18+
remove the content.
19+
20+
You can process multiple keywords in one run that ensures full and
21+
consistent coverage. The result is a clean, redacted document that is safe
22+
to share.
1923
2024
KEYWORD REDACTION FEATURES:
2125
✓ Multi-keyword search (process multiple terms)

0 commit comments

Comments
 (0)