A modular Python package that provides a split-screen interface for viewing PDF files alongside their corresponding JSON extracted content. Perfect for reviewing and validating PDF data extraction accuracy.
- Split-Screen Interface: View PDF and JSON files side by side
- PDF Viewer:
- Page navigation (previous/next)
- Zoom in/out controls
- Multi-page support
- Smooth rendering using PyMuPDF
- JSON Viewer:
- Tree view for hierarchical navigation
- Raw JSON view with syntax highlighting and line numbers (NEW!)
- Table view for spreadsheet-like editing
- Search functionality
- Expandable/collapsible nodes
- Advanced text editor with:
- Line numbers display
- Undo/Redo support (unlimited)
- Find and Replace dialog
- Case-sensitive and whole-word search options
- Edit mode for modifying JSON data
- Double-click cells to edit in table view
- Real-time sync between table and JSON views
- Auto-CSV export when saving
- Auto-backup before saving changes
- JSON validation before saving
- Save and Save As functionality
- User-Friendly:
- File browser dialogs
- Keyboard shortcuts
- Auto-detection of matching files
- Resizable panels
- Status bar with feedback
# Clone or download the repository
cd split-panel-ui
# Install dependencies
pip install -r requirements.txt
# Install the package
pip install -e .pip install PyMuPDF Pillow# Run with no files (use GUI to load)
python -m split_panel_viewer
# Or if installed
split-panel-viewer# Load PDF only
python -m split_panel_viewer path/to/document.pdf
# Load both PDF and JSON
python -m split_panel_viewer path/to/document.pdf path/to/data.jsonfrom split_panel_viewer import SplitPanelApp
# Create and run the application
app = SplitPanelApp()
app.run()
# Or with initial files
app = SplitPanelApp(
pdf_file="document.pdf",
json_file="data.json"
)
app.run()Ctrl+P- Open PDF fileCtrl+J- Open JSON fileCtrl+B- Open both files (with auto-detection)Ctrl+L- Clear all loaded filesCtrl+S- Save JSON changes (when in edit mode)Ctrl+Q- Quit application
Ctrl+Z- UndoCtrl+YorCtrl+Shift+Z- RedoCtrl+F- FindCtrl+H- Find and Replace
split-panel-ui/
├── split_panel_viewer/
│ ├── __init__.py # Package initialization
│ ├── app.py # Main application class
│ ├── components/
│ │ ├── __init__.py
│ │ ├── pdf_viewer.py # PDF viewer component
│ │ └── json_viewer.py # JSON viewer component
│ └── utils/
│ └── __init__.py
├── examples/ # Example files (you can add samples here)
├── tests/ # Unit tests (future)
├── requirements.txt # Python dependencies
├── setup.py # Package setup configuration
└── README.md # This file
A reusable component for displaying PDF files with navigation and zoom controls.
from split_panel_viewer.components import PDFViewer
# In your Tkinter application
pdf_viewer = PDFViewer(parent_frame)
pdf_viewer.pack(fill=tk.BOTH, expand=True)
pdf_viewer.load_pdf("document.pdf")Features:
- Page-by-page navigation
- Zoom controls (50% to 300%)
- Scrollable canvas
- Clean, intuitive interface
A component for displaying JSON data in tree and text formats.
from split_panel_viewer.components import JSONViewer
# In your Tkinter application
json_viewer = JSONViewer(parent_frame)
json_viewer.pack(fill=tk.BOTH, expand=True)
json_viewer.load_json("data.json")Features:
- Tree view with expandable nodes
- Raw JSON view with syntax highlighting
- Search functionality
- Tabbed interface for switching views
- Edit mode for modifying JSON
- Automatic backup creation before saving
- Real-time JSON validation
- Unsaved changes indicator
The main application that combines both viewers.
from split_panel_viewer import SplitPanelApp
app = SplitPanelApp()
app.load_pdf("document.pdf")
app.load_json("data.json")
app.run()- PyMuPDF (fitz): PDF rendering and manipulation
- Pillow (PIL): Image processing for PDF display
- tkinter: GUI framework (included with Python)
-
Launch the application:
python -m split_panel_viewer
-
Load files:
- Click "Load Both" button
- Select your PDF file
- The app will look for a matching
.jsonfile - Or manually select the JSON file
-
Review content:
- Navigate through PDF pages on the left
- Browse JSON structure on the right
- Use search to find specific content
- Switch between tree and raw JSON views
-
Edit JSON (if needed):
- Click the "Edit" button in the JSON viewer
- Modify the JSON content directly in the text view
- The app will show a "● Modified" indicator
- Press
Ctrl+Sor click "Save" to save changes - Automatic backup is created before saving (filename_backup_YYYYMMDD_HHMMSS.json)
- JSON is validated before saving to prevent errors
-
Verify accuracy:
- Compare PDF content with extracted JSON data
- Use zoom to examine PDF details
- Expand JSON nodes to check nested data
- Make corrections directly in edit mode
📝 Editing JSON Files: The viewer includes full editing capabilities with automatic backups. See EDITING_GUIDE.md for detailed instructions on editing, saving, and managing backups.
To test the viewer, you can create sample files:
{
"title": "Sample Document",
"pages": [
{
"page_number": 1,
"content": "This is the first page",
"metadata": {
"extracted_at": "2024-01-15",
"confidence": 0.95
}
}
],
"summary": {
"total_pages": 1,
"word_count": 125
}
}The package is designed to be modular. You can:
- Extend the viewers with additional features
- Create custom styling with ttk themes
- Add new file format support
- Integrate with data extraction pipelines
Potential improvements for future versions:
- Support for multiple file formats (XML, YAML, etc.)
- Diff view to compare multiple JSON files
- Export annotations and notes
- Batch file processing
- Plugin system for custom viewers
- Dark mode theme
- Configuration file support
- Ensure PyMuPDF is installed:
pip install PyMuPDF - Check if the PDF file is corrupted
- Try a different PDF file
- Validate your JSON file using a JSON validator
- Check for encoding issues (file should be UTF-8)
- Verify the file has a
.jsonextension
- Verify all dependencies are installed
- Check Python version (3.8+ required)
- Try running with
python -vfor verbose output
Contributions are welcome! Please feel free to submit pull requests or open issues.
MIT License - feel free to use this package in your projects.
For questions or issues, please open an issue on the GitHub repository.
Note: This is an educational/development tool. For production use, consider adding error handling, logging, and additional validation features.