scientific-report-pdf
Generates a structured scientific PDF report from a JSON input file. No LaTeX or pandoc required — uses reportlab for pure-Python PDF rendering.
Usage
python3 skills/scientific-report-pdf/scripts/scientific_report_pdf.py --input-json report.json
python3 skills/scientific-report-pdf/scripts/scientific_report_pdf.py --input-json report.json --output-dir /tmp/
python3 skills/scientific-report-pdf/scripts/scientific_report_pdf.py --describe-schema
Input JSON Structure
{
"title": "The Sound of Molecules",
"authors": ["ReportAgent", "MusicAnalyst"],
"subtitle": "CS1 Investigation | LAMM Research Platform",
"abstract": "We present ...",
"sections": [
{"type": "heading", "level": 1, "text": "1. Introduction"},
{"type": "text", "text": "Sonification has been applied to ..."},
{
"type": "table",
"label": "Table 1",
"caption": "RDKit descriptors for 16 compounds.",
"headers": ["Compound", "MW", "LogP"],
"rows": [["aspirin", "180.2", "1.19"], ["ibuprofen", "206.3", "3.72"]]
},
{
"type": "figure",
"label": "Figure 1",
"caption": "Era-match heatmap.",
"path": "/path/to/era_match.png"
},
{
"type": "panel",
"label": "Figure 2",
"caption": "Mean similarity by drug class.",
"panel_type": "bar",
"figsize": [10, 5],
"data": {
"categories": ["NSAID", "Opioid", "Stimulant"],
"series": [{"name": "Bach", "values": [0.4, 0.7, 0.3], "color": "#c0392b"}],
"xlabel": "Drug class",
"ylabel": "Mean cosine similarity",
"title": "Harmonic Affinity by Drug Class"
}
},
{"type": "pagebreak"},
{
"type": "panel",
"label": "Figure 3",
"caption": "Cosine similarity heatmap.",
"panel_type": "heatmap",
"data": {
"values": [[0.8, 0.3], [0.2, 0.9]],
"row_labels": ["aspirin", "fentanyl"],
"col_labels": ["Bach", "Beethoven"],
"cmap": "YlOrRd",
"annotate": true
}
}
],
"metadata": {
"investigation_id": "cs1_sound_of_molecules",
"platform": "LAMM Infinite",
"agents": ["SoundAgent1", "MusicAnalyst", "ReportAgent"]
}
}
Section Types
| type |
Required fields |
Description |
heading |
level (1-3), text |
Section heading |
text |
text |
Paragraph body |
table |
headers, rows |
Data table with optional label, caption, highlight_col |
figure |
path |
Embed existing PNG/JPG |
panel |
panel_type, data |
Auto-generate matplotlib figure |
pagebreak |
— |
Force page break |
hr |
— |
Horizontal rule |
Panel Types
| panel_type |
Required data fields |
heatmap |
values (2D array), row_labels, col_labels |
matrix |
same as heatmap |
bar |
categories, series (list of {name, values, color}) |
grouped_bar |
same as bar |
scatter |
x, y |
line |
x, y |
Output
{
"pdf_path": "/tmp/The_Sound_of_Molecules_20260403_001234.pdf",
"n_pages": 8,
"n_figures": 4,
"size_kb": 512
}
Dependencies
reportlab — PDF generation
matplotlib — auto-generated panel figures
pillow — RGBA→RGB image conversion
pypdf (optional) — page count in output
1---2name: scientific-report-pdf3description: Generate a structured scientific PDF report from a JSON description. Accepts a JSON file specifying title, authors, abstract, sections (headings, text, tables, figures), and inline data panels (heatmap, bar, scatter, line). Produces a publication-style A4 PDF using reportlab with no LaTeX dependency. All figures are either loaded from PNG paths or generated on-the-fly from inline data.4---56# scientific-report-pdf78Generates a structured scientific PDF report from a JSON input file. No LaTeX or pandoc required — uses reportlab for pure-Python PDF rendering.910## Usage1112```bash13python3 skills/scientific-report-pdf/scripts/scientific_report_pdf.py --input-json report.json14python3 skills/scientific-report-pdf/scripts/scientific_report_pdf.py --input-json report.json --output-dir /tmp/15python3 skills/scientific-report-pdf/scripts/scientific_report_pdf.py --describe-schema16```1718## Input JSON Structure1920```json21{22 "title": "The Sound of Molecules",23 "authors": ["ReportAgent", "MusicAnalyst"],24 "subtitle": "CS1 Investigation | LAMM Research Platform",25 "abstract": "We present ...",26 "sections": [27 {"type": "heading", "level": 1, "text": "1. Introduction"},28 {"type": "text", "text": "Sonification has been applied to ..."},29 {30 "type": "table",31 "label": "Table 1",32 "caption": "RDKit descriptors for 16 compounds.",33 "headers": ["Compound", "MW", "LogP"],34 "rows": [["aspirin", "180.2", "1.19"], ["ibuprofen", "206.3", "3.72"]]35 },36 {37 "type": "figure",38 "label": "Figure 1",39 "caption": "Era-match heatmap.",40 "path": "/path/to/era_match.png"41 },42 {43 "type": "panel",44 "label": "Figure 2",45 "caption": "Mean similarity by drug class.",46 "panel_type": "bar",47 "figsize": [10, 5],48 "data": {49 "categories": ["NSAID", "Opioid", "Stimulant"],50 "series": [{"name": "Bach", "values": [0.4, 0.7, 0.3], "color": "#c0392b"}],51 "xlabel": "Drug class",52 "ylabel": "Mean cosine similarity",53 "title": "Harmonic Affinity by Drug Class"54 }55 },56 {"type": "pagebreak"},57 {58 "type": "panel",59 "label": "Figure 3",60 "caption": "Cosine similarity heatmap.",61 "panel_type": "heatmap",62 "data": {63 "values": [[0.8, 0.3], [0.2, 0.9]],64 "row_labels": ["aspirin", "fentanyl"],65 "col_labels": ["Bach", "Beethoven"],66 "cmap": "YlOrRd",67 "annotate": true68 }69 }70 ],71 "metadata": {72 "investigation_id": "cs1_sound_of_molecules",73 "platform": "LAMM Infinite",74 "agents": ["SoundAgent1", "MusicAnalyst", "ReportAgent"]75 }76}77```7879## Section Types8081| type | Required fields | Description |82|------|----------------|-------------|83| `heading` | `level` (1-3), `text` | Section heading |84| `text` | `text` | Paragraph body |85| `table` | `headers`, `rows` | Data table with optional `label`, `caption`, `highlight_col` |86| `figure` | `path` | Embed existing PNG/JPG |87| `panel` | `panel_type`, `data` | Auto-generate matplotlib figure |88| `pagebreak` | — | Force page break |89| `hr` | — | Horizontal rule |9091## Panel Types9293| panel_type | Required data fields |94|-----------|---------------------|95| `heatmap` | `values` (2D array), `row_labels`, `col_labels` |96| `matrix` | same as heatmap |97| `bar` | `categories`, `series` (list of `{name, values, color}`) |98| `grouped_bar` | same as bar |99| `scatter` | `x`, `y` |100| `line` | `x`, `y` |101102## Output103104```json105{106 "pdf_path": "/tmp/The_Sound_of_Molecules_20260403_001234.pdf",107 "n_pages": 8,108 "n_figures": 4,109 "size_kb": 512110}111```112113## Dependencies114115- `reportlab` — PDF generation116- `matplotlib` — auto-generated panel figures117- `pillow` — RGBA→RGB image conversion118- `pypdf` (optional) — page count in output