Omniscope Custom Blocks › Outputs/Report-to-PDF-batch-output

Multi-tenant Report to PDF

Prints one Report tab once per scenario of a multi-tenant configuration, saving a PDF file per scenario in a folder.

Outputs › PDF Python

Open the demo in Omniscope Download demo.ioz Sample data: placeholder.csv Sample data: scenarios.csv Source on GitHub

Omniscope custom block · Outputs

One Report design, a PDF for every region, customer or user who sees their own version of it.

Python · visokio-omniprint (Chrome), pandas · visokio-omniprint installed on first run; needs Chrome or the block's Docker image

The problem it solves

A regional sales pack is one Report with a multi-tenant configuration: each regional manager sees their region. At month end each manager also wants the pack as a PDF. Printing it by hand means opening the Report six times, once per scenario, and naming six files.

This block reads the configuration and prints the tab once per scenario, saving <Report>-<scenario>.pdf for each.

How it works

What goes in

Scenarios

An invented multi-tenant configuration: one scenario per sales region, with the account manager who receives it.

scenario Region Account manager
north North Priya Shah
midlands Midlands Tom Hughes
south-east South East Grace Okafor
south-west South West Owen Price
scotland Scotland Isla Fraser
wales Wales Rhys Morgan

6 rows in the sample file.

The options

Option Demo setting What it does
Report tab URL http://127.0.0.1:24679/Sales/Regional%20Review.iox/r/Region%20Pack/#Summary The tab to print, without a scenario.
Scenario field (empty: scenario) The field holding the scenario IDs.
Output folder a folder on the server Where the PDFs go (created if missing).
Page width / height (pixels) (empty) Override the Report's page size.
Loading delay (seconds) 3 Extra wait before printing, for slow charts.
Username / Password (empty) For a Report behind Basic Authentication.

What comes out

PDF files written (first 3)

Scenario URL PDF filename PDF path
north .../Region%20Pack/s/north/#Summary Region Pack-north.pdf <folder>/Region Pack-north.pdf
midlands .../Region%20Pack/s/midlands/#Summary Region Pack-midlands.pdf <folder>/Region Pack-midlands.pdf
south-east .../Region%20Pack/s/south-east/#Summary Region Pack-south-east.pdf <folder>/Region Pack-south-east.pdf

6 records in all, one per scenario.

Where it pays off

Sales: Regional packs

The same monthly pack for each region, each showing only its own figures, ready for each regional manager.

Customer reporting: Statements per customer

A usage or account statement for every customer in the configuration, named by customer ID for a portal upload.

Franchises and branches: Branch scorecards

One scorecard per branch from a single design, printed after the weekly data load.

Membership bodies: Member reports

An annual summary for each member organisation, from one Report and the member list.

Use cases describe typical scenarios and are illustrative; the sample data is invented.

Why do this in Omniscope

How it fits into an Omniscope workflow

Multi-tenant configuration (Text Input or Database) → Multi-tenant Report to PDF → Join (recipients by scenario) → Batch Output (email)

Try it

  1. Open the demo project (demo.iox on the demo server, or import demo.ioz from this folder). It holds the scenarios, the block, not run (it needs Chrome on the server, a multi-tenant Report and a folder to write to), and a File block with placeholder.csv: what the block outputs for the sample.
  2. The question: which file was made for each region?
  3. Look at the placeholder records: one per scenario, with its address and file.
  4. To print for real, on a server with Chrome (or Docker): point the block at a tab of your own multi-tenant Report, connect the same configuration and choose an output folder.

Running in Omniscope

Omniscope workflow
Omniscope workflow

The demo project's workflow: the sample data, the block, and a Validate data check on its output.

Language and libraries

Python. It uses visokio-omniprint (MIT), which drives Chrome with selenium (Apache License 2.0), and pandas (BSD 3-Clause).

pandas is part of Omniscope's Python environment. visokio-omniprint is listed in the block's dependencies, so Omniscope installs it with pip on first run. Chrome must be on the machine running Omniscope, or the server must run custom blocks in Docker, where the block uses an image with Chrome included.

Tested

The block is covered by automated tests that run its script against a stand-in for Omniscope's Python API and a stand-in for Chrome (no page is printed): the sample, with the print address checked; a login that opens the page but stays out of the output; another scenario field and IDs with spaces, &, /, numbers and gaps; a tab address without / before #, and without a tab; repeated scenarios; a print failure, with the password hidden; empty input; bad options (no scenario field, an address that already holds a scenario, no folder); and 2,000 scenarios into a new folder.

Reference

Fields it reads

NameTypeWhat it does
Scenario fieldFieldThe field holding the scenario IDs, one per record. Empty: the field called scenario.

Options

NameTypeWhat it does
Report tab URLTextThe address of the tab to print, without a scenario, such as http://127.0.0.1:24679/Folder/Project.iox/r/Report/#Tab.
Output folderFileThe folder the PDF files are saved in, on the machine running Omniscope. Created if missing; files with the same name are replaced.
Page width (pixels)Whole numberOptional. Overrides the Report's page size (A4, or the Report's fixed size).
Page height (pixels)Whole numberOptional. Overrides the Report's page size (A4, or the Report's fixed size).
Loading delay (seconds)Whole numberExtra seconds to wait after the Report has finished drawing, before printing. Raise it if charts come out half drawn.
UsernameTextOptional. For a Report behind Basic Authentication.
PasswordPasswordOptional. Used only to open the page; not written to the output.

Outputs

OutputWhat it holds
PDFsOne record per PDF written: Scenario, URL, PDF filename, PDF path.