2.3 KiB
2.3 KiB
PDF Export Functionality
The gallery now includes the ability to export multiple plots to a merged PDF with grid layout.
Features
- Select up to 4 plots from any gallery page
- Automatic grid layout (1x1, 1x2, 2x2)
- Export to PDF with proper scaling
- Keyboard shortcuts for easy access
Usage
Selecting Plots
- Press Ctrl+E to enter selection mode
- Click on up to 4 plot thumbnails to select them
- Selected plots will show a checkmark overlay
- A counter shows how many plots are selected (e.g., "2/4 selected")
Exporting
- After selecting plots, click the 📄 export button (appears in floating buttons)
- The system will show export instructions with:
- JSON data for the export request
- Command to run the export script
- Copy the JSON data and save it as
export_request.json - Run the export command in your terminal
Keyboard Shortcuts
- Ctrl+E: Toggle selection mode
- Escape: Clear all selections and exit selection mode
Export Methods
The system supports two PDF merging methods:
Method 1: pdfjam (Recommended)
# Install on Ubuntu/Debian
sudo apt-get install texlive-extra-utils
# Check if available
python export_plots.py --check-deps
Method 2: Python libraries
# Install Python dependencies
pip install PyPDF2 reportlab
# Check if available
python export_plots.py --check-deps
Export Script Usage
# Basic usage
python export_plots.py export_request.json
# Specify output file
python export_plots.py export_request.json --output my_plots.pdf
# Check available dependencies
python export_plots.py --check-deps
JSON Request Format
{
"plots": [
"/path/to/plot1.pdf",
"/path/to/plot2.pdf"
],
"layout": {
"rows": 1,
"cols": 2
},
"output_name": "merged_plots.pdf"
}
Layout Options
- 1 plot: 1x1 grid
- 2 plots: 1x2 grid (horizontal)
- 3 plots: 2x2 grid (one empty slot)
- 4 plots: 2x2 grid (full)
Technical Details
The export functionality consists of:
- Frontend: JavaScript selection UI and export manager
- Backend: Python script for PDF merging
- CSS: Styling for selection mode and overlays
The system is designed to work without requiring a web server, using file-based communication between the browser and Python script.