BookmarkSubscribeRSS Feed

From SAS Visual Analytics to Pixel‑Perfect PDFs with a Local LLM (Part 1): Meet the Tech Stack

Started yesterday by
Modified yesterday by
Views 78

In this series, we’ll build an end‑to‑end pipeline that can:

 

  1. Pull content from SAS Viya Visual Analytics using REST API endpoints,
  2. Optionally use a local LLM (Ollama) to generate commentary, titles, or narrative text, and
  3. Produce a polished PDF report using Python + ReportLab.

 

This first article sets the stage: what each technology does, why it’s a good fit, and how they connect.

 

Articles in this series: 
From SAS Visual Analytics to Pixel‑Perfect PDFs with a Local LLM (Part 1): Meet the Tech Stack   (this article)
From SAS Visual Analytics to Pixel‑Perfect PDFs with a Local LLM (Part 2): Understanding the Buildin... 

 

Why this stack?

 

The goal: automate and industrialize “report delivery”

 

Many teams build great reports in Visual Analytics, but then need to export, distribute, archive, and brand them consistently—often outside the interactive VA user interface. The Visual Analytics REST APIs provide structured ways to export report content (PDF, images, data extracts) and even perform some report operations programmatically.

 

From there, ReportLab gives you full control to create “print‑ready” PDFs: layout, typography, headers/footers, page templates, tables, charts, and more—without relying on a browser renderer.

 

Finally, Ollama allows you to run an LLM locally and call it over an API, so you can add narrative text (executive summaries, explanations, key takeaways) while keeping data in your environment.

 

 

Technology #1 — SAS Viya Visual Analytics REST APIs (capabilities)

 

SAS provides a dedicated Visual Analytics API that focuses on “basic tasks with reports,” such as exporting PDFs and images, exporting data, and working with report packages.

 

 

Key export endpoints you’ll see in this series

 

The API groups endpoints around common output needs, including direct exports like:

 

  • Export a report as PNG: /reports/{reportId}/png
  • Export data extracts to CSV : /reports/{reportId}/csv

 

Programmatic report operations (beyond exporting)

 

The Visual Analytics API also includes a report operation endpoint (/visualAnalytics/reports) that accepts a list of operations executed sequentially (all must succeed for persistence). Supported operations include:

 

  • addData, changeData, applyDataView, addPage, addObject, setParameterValue

 

This matters because it opens the door to parameter-driven automation: e.g., update parameters, export an image, then assemble a final deliverable.

 

In this series, we’ll primarily leverage the export capabilities (images/data) as building blocks for a custom PDF “report pack” produced in Python.

 

 

Technology #2 — ReportLab (why it’s a great PDF engine)

 

What is ReportLab

 

ReportLab is a Python library that lets you directly generate PDF documents programmatically. It also supports charts and graphics in bitmap/vector formats and is designed for high-volume, automated document production.

 

The user guide highlights a practical point: PDF is a complex binary format and not something you realistically “hand craft.” ReportLab provides a direct PDF generation approach—no “print driver” and no intermediate step—often making automated report generation much faster and more controllable than UI-driven pipelines.

 

 

Two levels of control: Canvas and Platypus

 

ReportLab offers multiple abstraction layers:

 

  • pdfgen.Canvas: low-level drawing (absolute positioning, shapes, images, text)
  • PLATYPUS (Page Layout And Typography Using Scripts): high-level layout engine that “flows” elements like paragraphs, tables, and images across frames/pages automatically

 

PLATYPUS is particularly useful for multi-page documents because it separates content from layout decisions, using concepts like DocTemplatesPageTemplates, Frames, and Flowables.

 

 

Why ReportLab pairs well with Visual Analytics outputs

 

Visual Analytics exports can give you:

 

  • report images (PNG/SVG),
  • and data extracts (CSV/TSV/XLSX).

 

ReportLab can then:

 

  • place exported visuals in a branded PDF layout,
  • add cover pages, headers/footers, disclaimers, TOC, page numbers,
  • and generate narrative sections and tables around those VA outputs.

 

For more information about ReportLab.

 

 

Technology #3 — Ollama (and why running it locally is a strong option)

 

What Ollama brings

 

Ollama is positioned as an easy way to get up and running with large language models locally, and it provides an API reference you can call from your applications.

 

The API includes endpoints like:

 

  • POST /api/generate for text generation, with optional streaming or single-response mode
  • POST /api/chat for chat-style interactions
  • support for structured output via format=json (useful when you want a predictable JSON payload for your automation)

 

 

Why “local LLM” is compelling in enterprise reporting

 

In many reporting scenarios, the primary concerns are data governance and cost control:

 

  1. Privacy & data control: keeping prompts and content local reduces exposure of sensitive report data to external services. Articles describing local LLM usage highlight privacy as a core benefit of running models locally.
  2. Offline / network independence: once models are downloaded, local inference enables workflows that don’t depend on external availability or network latency—useful for controlled environments.
  3. Predictable cost: local execution avoids “per-token” billing and rate limits typical of hosted APIs; guides comparing local vs cloud emphasize eliminating API costs as a major advantage.
  4. Automation-friendly API: Ollama exposes a simple REST interface (e.g., /api/generate) that fits naturally into Python pipelines alongside SAS REST calls.

 

In this series, we’ll use Ollama as an optional “narration engine”—for example: generating executive summaries from metrics, writing captions for visuals, or explaining anomalies—while keeping the report assembly deterministic and auditable in Python.

 

For more information about Ollama.

 

 

How the pieces fit together (reference architecture)

 

Here’s the mental model we’ll implement across the series:

 

  1. Extract from SAS Visual Analytics
    • Call VA REST API endpoints to export report content (e.g., PNG for specific visuals, CSV for report data).
  2. Enrich with an LLM (optional)
    • Send a compact, controlled prompt to Ollama: “Summarize the KPI deltas” or “Generate 3 bullet insights.”
  3. Assemble a final deliverable in ReportLab
    • Use PLATYPUS flowables to combine: title page, text sections, images, and tables into a single branded PDF.

 

 

Practical prerequisites (high level)

 

To follow along later, you’ll want:

 

  • A SAS Viya environment with access to the Visual Analytics API endpoints and a report you can export.
  • Python environment with ReportLab installed (we’ll reference PLATYPUS patterns heavily).
  • Ollama installed locally if you want the LLM portion (optional but recommended for the “narrative” features).

 

 

Teaser: why this approach is worth it

 

By combining:

 

  • SAS Viya REST exports (reliable access to visual + data artifacts),
  • ReportLab (full control of branded PDF production),
  • and Ollama (local, API-driven narrative generation),

 

…you get a workflow that is automatable, auditable, and enterprise-friendly: great for scheduled deliveries, CI/CD style promotion of report assets, or producing “board pack” PDFs at scale.

 

Articles in this series: 
From SAS Visual Analytics to Pixel‑Perfect PDFs with a Local LLM (Part 1): Meet the Tech Stack   (this article)
From SAS Visual Analytics to Pixel‑Perfect PDFs with a Local LLM (Part 2): Understanding the Buildin... 

 

Find more articles from SAS Global Enablement and Learning here.

Contributors
Version history
Last update:
yesterday
Updated by:

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started