Embed native plots in a PDF report
Insert native chart snapshots directly into a templated PDF without intermediate image files.
// Requires Aner 0.0.10 or greater and PDF module 0.1.1 or greater.
// Install first: aner install pdf
// Synthetic observations for a reporting example, not a fitted model.
import aner.pdf
import aner.plot
let days = List(1.0, 2.0, 3.0, 4.0, 5.0)
let values = List(2.0, 2.7, 2.4, 3.3, 3.8)
let chart = plot.line(days, values)
.title("Synthetic observations by day")
.labels("Day", "Measured value (a.u.)")
.caption("Five synthetic observations; no uncertainty estimates or fitted trend.")
.theme(plot.theme("light"))
.size(width: 640, height: 400)
let branding = pdf.template(header: "Analysis report", footer: "Page {page} of {pages}")
let report = pdf.document(title: "Measurements and figure", author: "Research team")
pdf.with_template(report, branding)
pdf.heading(report, "Measurements and figure")
pdf.text(report, "The figure below is captured directly from an immutable Aner Chart.")
pdf.plot(report, chart, width: 450.0, height: 280.0)
pdf.table(report, List("Day", "Measured value (a.u.)"),
List(List("1", "2.0"), List("2", "2.7"), List("3", "2.4"),
List("4", "3.3"), List("5", "3.8")))
let receipt = pdf.create("plot-report.pdf", report)
print(pdf.to_json(receipt))
// Read the saved PDF; chart labels remain selectable/extractable text.
let extracted = pdf.read("plot-report.pdf")
print(pdf.extract_text(extracted))
Make it your experiment.
Use Aner 0.0.10 or newer. Save this program as examples/pdf_plot_report.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/pdf_plot_report.aner
aner run examples/pdf_plot_report.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Requires Aner 0.0.10 or greater and an explicitly installed compatible PDF module. Save the download at `examples/pdf_plot_report.aner` beneath a fresh project directory and run from that project root. The example creates a PDF and preserves existing output paths. Direct chart insertion requires PDF module 0.1.1 or greater. Charts are static snapshots of the authored view.
aner --version
aner install pdf
aner check examples/pdf_plot_report.anerBundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution