Report#

Report APIs to create presentations and pdfs.

Image#

Create an image with name, type, and size in the active report session.

Syntax#

img = Image(name=<’name’>,source=<’file’>,path=<’path’>)

Arguments#

name

The name of the image. Type = method img.name=<’name’>

path

The path to the image if the source is of type “file”. Type = string img.path=<’image_file_path’>

caption

The image caption. Type = string img.caption = <’image_caption>

session

Returns the current session object. Type = object sesObj = img.session

setAttributes()

Set multiple attributes simultaneously. Type = method img.setAttributes(name=<’name’>,source=<’file’>,path==<’image_file_path’>)

source

Type = string img.source=<’graphic’/’file’> Note: In 2023.0 only ‘file’ is supported

type

The image file type. Type = string img.type=<’png’/’jpg’/’bmp’/’tif’/’avi’/’gif’/’h3d’>

Example#

image = Image()
image4.path = 'D:/temp/demo_image.png'
image4.caption = 'Demo Image'

Layout#

Handling of the report layouts.

Syntax#

reportSession.getLayouts()

Arguments#

name

The layout name. Type = string layout.name

getPlaceholderInfo

Returns a list of the placeholder types and the positions. Type = method

Example#

from hw.report.types import *
import os
session = ReportSession(name='MyReportSession')
for layout in session.getLayouts():
    print('Layout = '+layout.name)
    print('Placeholders:')
    print(layout.getPlaceholderInfo())
    print('--------------------')

Presentation#

Create or save a presentation in the active report session.

Syntax#

pres=Presentation()

Arguments#

setAttributes()

Set multiple attributes simultaneously. Type = method pres.setAttributes(name=<name>,workDir=<’workDir’>,session=’ReportSession1’)

name

The name of the presentation. Type = string pres.name=<’name’>

size

The active session. Type = method pres.size(<’16:9’, ‘4:3’>

session

The active session. Type = object sesObj = pres.session

resolution

The presentation default resolution. Type = string pres.resolution = <’HD’/’UHD’/’Desktop’/’Medium’>

savePDF

The presentation default resolution. Type = method Optional Attributes range=<’range_syntax’> pres.savePDF(<’pdfFile’>, range=’2,5-7’)

savePPTX

The presentation default resolution. Type = method Optional Attributes open=<True/False> (Default False) mode=<’write’/’append’/’prepend’> (Default ‘write’) range=<’range_syntax’> pres.savePPTX(<’pptFile’>,open=True,mode=’append’, range=’2,5-7’)

template

The presentation template which contains the layouts. Type = string pres.template=<’template_file’>

Example#

templatefile = os.path.join(src_path, "data", "pptTemplate.pptx")
outfile = os.path.join(os.path.expanduser("~"), "Documents", "alllayout.pptx").replace("\\","/")
pres = Presentation()
pres.template=templatefile
pres.resolution = 'UHD'
pres.savePPTX(outfile, open=True, mode='append', range='2,5-7')

ReportManager#

Report Manager to handle sessions.

Syntax#

rep_man=ReportManager()

Arguments#

activeSession

Get the active report session. Type = string activeSession = rep_man.activeSession Set the active report session. rep_man.activeSession = <ReportSessionName>

getAllSessionNames()

Get a list of all report sessions. Type = method sessionList = rep_man.getAllSessionNames()

Example#

for reportSession in rep_man.getAllSessionNames():
print(reportSession)

ReportSession#

Create a report session.

Syntax#

rep_ses=ReportSession()

Arguments#

activePresentation

Active presentation of the report session. Type = object activePresentation = rep_ses.activePresentation

reset

Resets the report session. Type = method rep_ses.reset()

delete

Delete any entity in the session using the entity object. Type = method rep_ses.delete(<object>)

name

Create a report session with the given name. The name of a created Report Session can’t be changed. Type = string rep_ses=ReportSession(name=”ReportSession1”)

get

Get method on ReportSession to retrieve a handle for any entity. Type = method entity_obj=rep_ses.get(<entity_class>,<”name”> )

getLayouts

Get list of available layouts. Type = method layoutList = rep_ses.getLayouts()

Example#

from hw.report.types import *
import os
session = ReportSession(name='MyReportSession')
for layout in session.getLayouts():
    print('Layout = '+layout.name)
    print('Placeholders:')
    print(layout.getPlaceholderInfo())
    print('--------------------')
Layout = Divider Slide - Orange
Placeholders:
Slide Number Placeholder 5 : ['Slide Number', [5, 90, 22, 5]]
Title 1 : ['Center Title', [12, 45, 75, 9]]
None
--------------------
Layout = Two table
Placeholders:
Table1 : ['Table', [55, 33, 42, 62]]
Slide Number Placeholder 2 : ['Slide Number', [5, 90, 22, 5]]
Table2 : ['Table', [4, 18, 46, 50]]
Title 1 : ['Title', [5, 8, 89, 5]]
None
--------------------
Layout = One Table with Text and Image
Placeholders:
Title 1 : ['Title', [5, 8, 89, 5]]
Table Placeholder 4 : ['Table', [4, 18, 60, 62]]
Text Placeholder 5 : ['Text', [5, 82, 89, 7]]
Picture Placeholder 9 : ['Picture', [66, 18, 28, 62]]
None
........

Slide#

Create a slide in the active report session.

Syntax#

slide=Slide()

Arguments#

setAttributes()

Set multiple attributes simultaneously. Type = method slide.setAttributes(name=<’name’>,presentation=’Presentation1’)

name

The name of the slide. Type = string slide.name=<’name’>

presentation

Type = object (read only) pres=slide.presentation

layout()

Slide layout. Setting a new slide layout deletes the existing one. Type = method slide.layout(<’slide_layout_name’>

add()

Add an image, text or table. Type = method slimg= slide.add(<image/text/table>,name=<’name’>)

titleText

Slide title text. Type = string slide.titleText(<’Slide Title’>)

titlePosition

Slide title Position requires 4 positional arguments: x, y, width, and height. Type = double slide.titlePosition(x, y, width, height)

applySlidePlaceholderList ()

Placeholders from the referenced slide will be used. Match by id if exist in both slides, no placeholder type check. Type = method slide. applySlidePlaceholderList (<slide_id>)

Example#

pres = Presentation()
imagea = Image()
imagea.path = <'patha'>
imagea.caption = 'Image A'
slide = Slide('SlideOneImage', presentation=pres)
slide.layout("One Images Only")
slide.add(imagea,"imga",position="Picture1")

SlideImage#

Create a slide image in an existing slide.

Syntax#

slideimage=SlideImage(slide)

Arguments#

setAttributes()

Set multiple attributes simultaneously. Type = method slideimage.setAttributes(name=<name>, session=’ReportSession1’)

caption

The image caption. Type = string slideimage.caption = <’image_caption>

name

The slide name. Type = string slideimage.name=<’name’>

source

The slide image source file. Only type file is supported in 2023. Type = string slideimage.source=<’file’>

session

The report session where the slide image is located (read only) Type = object sesObj = slideimage.session

type

The slide image type. Type = string imageType = slideimage.type

path

The file path to the slide image. Type = string slideimage.path=<’file_path’>

position

The slide image position as list [<x>,<y>,<width>,<heigth>] Type = list slideimage.position=[5,10,20,50]

x

The slide image x value of the upper left corner in percentage. Type = double slideimage.x=<x>

y

The slide imagey value of the upper left corner in percentage. Type = double slideimage.y=<y>

width

The slide image width value in percentage. Type = double slideimage.width=<width>

heigth

The slide image height value in percentage. Type = double slideimage.heigth=<heigth>

Example#

slide_image = SlideImage(slide=<slide>, image=<image1>, position=[50, 13, 10, 21], name='SlideImage1')
slide_image.caption='Image 1'

SlideTable#

Create a slide table in the active report session.

Syntax#

sltab=SlideTable(slide)

Arguments#

setAttributes()

Set multiple attributes simultaneously. Type = method sltab.setAttributes(name=<name>,csvFile=<’csv_file’>)

name

The slide table name. Type = string sltab.name=<’name’>

session

The active report session. (Read only) Type = object sesObj = sltab.session

csvFile

The path to the table CSV file. Type = string sltab.csvFile=<’csv_file’>

caption

The slide table caption. Type = string sltab.caption=<’slide table caption’>

split

Turn auto split on/off. Type = Boolean sltab.split=<True/False>

splitBy

Split by rows/columns. Type = string sltab.splitBy=<’rows’/’columns’>

maxRows

The number of maximum rows where to split, default is 0. Type = integer sltab.maxRows(<integer>)

maxColumns

The number of maximum columns where to split, default is 0. Type = string sltab.maxColumns(<integer>)

position

The slide table position as list [<x>,<y>,<width>,<heigth>] Type = list sltab.position=[5,10,20,50]

x

The slide table x value of the upper left corner in percentage. Type = double sltab.x=<x>

y

The slide table y value of the upper left corner in percentage. Type = double sltab.y=<y>

width

The slide table width value in percentage. Type = double sltab.width=<width>

heigth

The slide image height value in percentage. Type = double slideimage.heigth=<heigth>

Example#

table = Table()
table.caption = 'Table caption'
table.csvFile = path5
table.split=True
table.maxColumns=5
table.maxRows=9
table.stretch

SlideText#

Create slide text.

Syntax#

slidetext=SlideText(slide)

Arguments#

setAttributes()

Set multiple attributes simultaneously. Type = method slidetext.setAttributes(name=<name>, session=’ReportSession1’)

name

The slide text name. Type = string slidetext.name=<’name’>

session

The report session where the text is located (read only) Type = object sesObj = slidetext.session

text

The text displayed in the slide text. Type = string slidetext.text=<’text’>

position

The slide image position as list [<x>,<y>,<width>,<heigth>] Type = list slidetext.position=[5,10,20,50]

x

The slide text x value of the upper left corner in percentage. Type = double slidetext.x=<x>

y

The slide text y value of the upper left corner in percentage. Type = double slidetext.y=<y>

width

The slide text width value in percentage. Type = double slidetext.width=<width>

heigth

The slide text height value in percentage. Type = double slidetext.heigth=<heigth>

Example#

slidetext = Slidetext(slide=<slide>, text='Demo Slide text, name='SlideText1')
slidetext.position=[5,10,20,50]

Table#

Create a table with a default name in the active session

Syntax#

tab=Table()

Arguments#

name

The table name. Type = string tab.name=<’name’>

session

The session where the table is located (read only). Type = object sesObj = tab.session

csvFile

Path to the table CSV file. Type = string tab.csvFile=<’csv_file’>

caption

The table caption. Type = string tab.caption=<’caption’>

split

Turn auto split on/off. Type = Boolean tab.split=<True/False>

splitBy

Split by rows and columns. Type = string tab.splitBy=<’rows’/’columns’>

stretch

Stretch the table to fill the available table width. Type = Boolean tab.stretch=<True/False>

maxRows

The number of the maximum rows where to split, default is 0. Type = string tab.maxRows(<integer>)

maxColumns

The number of maximum columns where to split, default is 0. Type = string tab.maxColumns(<integer>)

setAttributes()

Set multiple attributes simultaneously. Type = method tab.setAttributes(name=<name>,csvFile=<’csv_file’>)

Example#

table = Table()
table.caption = 'Table caption'
table.csvFile = path5
table.split=True
table.maxColumns=5
table.maxRows=9

Text#

Create text with the default name and default text in active report session.

Syntax#

txt=Text()

Arguments#

setAttributes()

Set multiple attributes simultaneously. Type = method txt.setAttributes(name=<’name’>, text=<’My text’>)

name

The text name. Type = string txt.name=<’name’>

session

The active session. (Read only) Type = object sesObj = txt.session

text

The text string. Type = string txt.text=<’text’>

Example#

txt=Text(name=<'name'>,text=<'My text'>,session=<session>)