Skip to content

Document Preview ​

GhostAI provides rich visual document previews with built-in PII redaction. View uploaded files directly in the browser — with sensitive content automatically redacted — without downloading or opening them in external applications.

Supported Preview Formats ​

FormatViewerFeatures
PDFNative browser viewerPage navigation, zoom, search, print
Word (.docx)HTML rendererFormatted text, tables, lists, images
Excel (.xlsx)Table rendererAll sheets with tab navigation, formatting
PowerPoint (.pptx)PDF conversionFull-fidelity slides via LibreOffice
CSVTable rendererAuto-parsed columns, formatting
HTMLSandboxed iframeSanitized rendering with XSS protection
MarkdownReact rendererFull GFM support with syntax highlighting
ImagesNative viewerJPEG, PNG, GIF, WebP, BMP, TIFF
ParquetTable rendererColumn names, row counts, sample data via pyarrow

Security Indicators ​

Files with detected security threats display visual indicators in preview:

IndicatorMeaning
Macro WarningVBA or XLM macros detected in Office document
Encrypted BadgeFile is password-protected and cannot be inspected
JavaScript WarningPDF contains JavaScript actions
Steganography AlertStatistical analysis suggests hidden data in image
Injection WarningPrompt injection patterns detected in file content

How It Works ​

┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────────┐
│  Upload  │───▶│  Scan &  │───▶│  Create  │───▶│   Preview    │
│   File   │    │  Detect  │    │ Redacted │    │   Modal      │
└──────────┘    └──────────┘    └──────────┘    └──────────────┘
                     │                                  │
                     ▼                                  ▼
              ┌──────────────┐               ┌──────────────────┐
              │ Deep PII Scan│               │ Toggle: Redacted │
              │ (hidden data)│               │   vs Original    │
              └──────────────┘               └──────────────────┘

Preview Flow ​

  1. Upload: File is uploaded and encrypted at rest
  2. Scan: Multi-layer PII detection runs on all content
  3. Deep Scan: Hidden content is inspected (see below)
  4. Redaction: A redacted copy is created with PII removed
  5. Preview: Click the file to open the visual preview modal
  6. Toggle: Admins can switch between redacted and original views

Deep PII Scanning ​

GhostAI goes beyond surface-level text to find PII hidden in document metadata, comments, and embedded content.

Word Documents (.docx) ​

LocationWhat's Scanned
Body textAll paragraphs, headings, lists
CommentsReview comments and replies
Tracked changesInsertions, deletions, revisions
Headers/FootersRunning headers and page footers
FootnotesFootnote and endnote content
TablesAll cell content
Text boxesFloating text frames

Excel Spreadsheets (.xlsx) ​

LocationWhat's Scanned
Cell valuesAll visible cells across all sheets
Cell commentsNote and threaded comment text
Hidden sheetsSheets marked as hidden
Named rangesRange name definitions
MetadataDocument properties and custom fields

PowerPoint (.pptx) ​

LocationWhat's Scanned
Slide textAll text boxes, shapes, and placeholders
Speaker notesPresenter notes per slide
Slide mastersTemplate text and branding
Embedded objectsLinked or embedded content
Tables & chartsData within slide elements

PDF Documents ​

LocationWhat's Scanned
Page textAll extracted text content
Form fieldsInteractive form data
AnnotationsComments, highlights, sticky notes
Embedded filesAttached documents
MetadataAuthor, title, subject, keywords

Images ​

DetectionWhat's Scanned
OCR textVisible text in the image
ID cardsDriver's licenses, passports, badges
Credit cardsVisible card numbers
Bank checksAccount numbers, routing numbers
FacesFor de-identification
EXIF metadataGPS, device info, timestamps

Redacted vs. Original View ​

Redacted View (Default) ​

The redacted view is shown by default for all users:

  • Text documents: PII replaced with entity type labels (e.g., [PERSON], [US_SSN])
  • Images: Sensitive regions blurred or covered with redaction boxes
  • Bank checks/IDs: Entire image blurred for maximum protection
  • PDFs: Redacted PDF with PII regions obscured

Original View (Admin Only) ​

Administrators and organization owners can toggle to the original, unredacted view:

  • Protected by role-based access control
  • Every access is audit-logged
  • Visual warning banner: "ORIGINAL — Contains PII"
  • Red border ring around the document

Access Control

Only users with admin or owner roles can view original (unredacted) files. All original file access is recorded in the audit log for compliance.

Download Options ​

Download Redacted Version ​

Download a copy of the file with all PII redacted:

  • Documents: PII text replaced with placeholders
  • Images: Sensitive regions blurred/covered
  • Available to all users

Download Redaction Certificate ​

For compliance, download a PDF certificate documenting:

  • File name and ID
  • Date and time of redaction
  • Number and types of PII entities found
  • Redaction method used
  • Compliance frameworks triggered (HIPAA, PCI-DSS, etc.)

Security Features ​

Content Sanitization ​

All rendered content is sanitized to prevent XSS attacks:

Content TypeProtection
HTML filesDOMPurify sanitization, sandboxed iframe
SVG imagesScript removal, event handler stripping
MarkdownHTML tag filtering, script blocking
CSSStyle attribute sanitization

Rendering Isolation ​

  • HTML and SVG rendered in sandbox="" iframes
  • Content Security Policy (CSP) headers
  • No external resource loading from rendered content
  • Dangerous file types (HTML, SVG, CSS) force download instead of inline display

Encrypted File Handling ​

When a password-protected or encrypted file is detected:

  • Clear message indicating the file is encrypted
  • No attempt to brute-force or bypass encryption
  • User advised to download and open locally
  • Encrypted status recorded in scan results

Large File Performance ​

FormatLimitBehavior
HTML500 KBTruncated with warning
Markdown200 KBTruncated with warning
Excel1,000 rowsPaginated display
CSV1,000 rowsPaginated display
PDFNo limitBrowser native viewer handles pagination

API Endpoints ​

Get File Preview Metadata ​

bash
curl http://localhost:8000/api/files/{file_id}/preview \
  -H "Authorization: Bearer YOUR_TOKEN"

Response:

json
{
  "file_id": "abc123",
  "filename": "report.docx",
  "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  "text_content": "Extracted text...",
  "pii_entities": [
    {"type": "PERSON", "text": "John Smith", "start": 10, "end": 20}
  ],
  "pii_redacted": true,
  "has_sensitive_image_content": false,
  "is_encrypted": false,
  "deep_scan_locations": ["comments", "tracked_changes", "headers"]
}

Get File (Redacted or Original) ​

bash
# Get redacted version (default)
curl http://localhost:8000/api/files/{file_id} \
  -H "Authorization: Bearer YOUR_TOKEN"

# Get original version (admin only)
curl http://localhost:8000/api/files/{file_id}?original=1 \
  -H "Authorization: Bearer YOUR_TOKEN"

Convert to PDF (for PPTX) ​

bash
curl http://localhost:8000/api/files/{file_id}/as-pdf \
  -H "Authorization: Bearer YOUR_TOKEN"

Download Redacted Copy ​

bash
curl http://localhost:8000/api/files/{file_id}/download-redacted \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -o redacted_report.docx

Configuration ​

LibreOffice (for PPTX Preview) ​

PPTX files are converted to PDF via LibreOffice for preview. Install it:

bash
# macOS
brew install --cask libreoffice

# Ubuntu/Debian
sudo apt-get install libreoffice

# Docker (included in GhostAI Docker image)

Environment Variables ​

bash
# File preview settings
MAX_PREVIEW_SIZE=52428800     # Max file size for preview (50MB)
PPTX_CONVERSION_TIMEOUT=60   # LibreOffice conversion timeout (seconds)

Best Practices ​

  1. Review redacted previews: Always verify redaction before sharing
  2. Use redaction certificates: For compliance documentation
  3. Limit original access: Restrict admin/owner roles to trusted users
  4. Monitor audit logs: Track who accesses original files
  5. Enable deep scanning: Catch PII in comments, notes, and metadata
  6. Download redacted copies: Share redacted versions instead of originals

RAG-Enhanced File Interaction ​

Files over 1 MB are automatically indexed for intelligent retrieval using RAG v2. When you ask a question about an attached file, GhostAI retrieves only the most relevant sections using hybrid BM25+semantic search. If multiple files are attached, cross-file retrieval lets you query across all of them at once — for example, comparing data in a CSV against definitions in a PDF.

See File Intelligence for full details.

Next Steps ​

SOC 2 Type II Certified | BAA Available | HIPAA-Ready