Reporting

PDF Reports: How to make cells "top-aligned" instead of bottom in Splunk 6.1.3?

grundsch
Communicator

Hi,
I am generating a PDF from a dashboard. A table has cell values with multiple lines, making the rows large. Other values in that row are aligned at the bottom of the row.
Is there a way to change the rendering in order to have top-aligned cells? (actually, like in the view)
Thanks,
Stéphane

0 Karma
1 Solution

grundsch
Communicator

second try, I've found a more simple patch...

The default cell aligment is actually defined in /opt/splunk/lib/python2.7/site-packages/reportlab/platypus/tables.py
It's just an attribute to change, and done.
Here's the diff:

splunk@hostname: [~/lib/python2.7/site-packages/reportlab/platypus]> diff -u tables.py.old tables.py
--- tables.py.old       2014-07-30 01:26:20.000000000 +0200
+++ tables.py   2014-11-14 11:23:12.157975142 +0100
@@ -42,7 +42,7 @@
     color = 'black'
     alignment = 'LEFT'
     background = 'white'
-    valign = "BOTTOM"
+    valign = "TOP"
     href = None
     destination = None
     def __init__(self, name, parent=None):

View solution in original post

grundsch
Communicator

second try, I've found a more simple patch...

The default cell aligment is actually defined in /opt/splunk/lib/python2.7/site-packages/reportlab/platypus/tables.py
It's just an attribute to change, and done.
Here's the diff:

splunk@hostname: [~/lib/python2.7/site-packages/reportlab/platypus]> diff -u tables.py.old tables.py
--- tables.py.old       2014-07-30 01:26:20.000000000 +0200
+++ tables.py   2014-11-14 11:23:12.157975142 +0100
@@ -42,7 +42,7 @@
     color = 'black'
     alignment = 'LEFT'
     background = 'white'
-    valign = "BOTTOM"
+    valign = "TOP"
     href = None
     destination = None
     def __init__(self, name, parent=None):

kiyop
Engager

In Splunk 7.x.x this has changed, you can find the file in $HOME$/Python2.7/Lib/site-packages/reportlab/platypus/tables.py, it is in the first function

0 Karma

grundsch
Communicator

I can't confirm this. I just downloaded 8.0.0, and the reportlab library is still the same, platypus is still having as default a Cell Alignment "Bottom".
In the archive (linux download, tgz), Python is still under $HOME/lib/python2.7 and not under $home/Python2.7
Are you sure you haven't installed Python yourself? Or are you using a different version/platform?

0 Karma

grundsch
Communicator

Ok, I've looked at the python code generating the PDFs (Splunk 6.1.3), and could make a change to force top-aligment:

splunk@hostname: [~/lib/python2.7/site-packages/splunk/pdf]> diff pdfrenderer.py.old pdfrenderer.py
365,367c365,369
<         if columnVAlignments is not None:
<             for i, valign in enumerate(columnVAlignments):
<                 tableStyleCommands.append(('VALIGN', (i, 0), (i, -1), valign))
---
> #        if columnVAlignments is not None:
> #            for i, valign in enumerate(columnVAlignments):
> #                tableStyleCommands.append(('VALIGN', (i, 0), (i, -1), valign))
>       for i in range(0,numDataCols):
>           tableStyleCommands.append(('VALIGN', (i, 0), (i, -1), 'TOP'))

So basically, the reporting engine (reportlab's pdfgen) is using as default the 'BOTTOM' cell alignment in tables. The PDFrenderer Script in Splunk has the possibility to overide this default, but somehow doesn't do it systematically.
The above patch sets the alignement for every colomn to 'TOP', whatever arguments would have been passed by other scripts. I have absolutely no idea what these arguments to the tableStyleCommands mean, but it works...
I'm not sure if this will have any side effect, so if any Splunk employee could add a comment, that would be great. Even better if this could be included in future releases 🙂

grundsch
Communicator

Splunk version: 6.1.3

0 Karma
Get Updates on the Splunk Community!

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud  In today’s fast-paced digital ...

Observability protocols to know about

Observability protocols define the specifications or formats for collecting, encoding, transporting, and ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...