Python scripting for PDF reports

Inheritance


If the available settings will not fulfill the expectations and more and deeper modification is required, it is possible to inherit the methods from the base class into the plugin Python script.

 

Example : re-order the header of the report

PDF_InheritanceSample


To change the appearance of the header section as first a inherited class of the same name (ReportUtility)has to be created.

Then the Report.py method cenheader has to be copied into the script and the required modification can be done there.


def ModifyActiveProgram(Operator: CENPyOlpProgramModifyOperator):

   

  # ======== create a PDF Report =============

  pdf = ReportUtility()

   pdf.setLanguage("fr")

   pdf.createAuxCommandsPDFReport(Operator, "")

   

# ============================================

 

class ReportUtility(ReportUtility):

  '''

   inherited Class "ReportUtility" for PDF Reports from report.py Base

   '''

  # re-order my own Report Header, inherited Method from Base Class

  def cenheader(self, Operator, path, portrLands):

      '''

      Defines the customized Header of the PDF Report, underneath common Header

      '''

      # general Infos Table

      self.ln(4)

      self.header_table(Operator)

      self.ln(20)

 

      # Rendering logo:

      filepath =  path + self.__headerLogo

      if not exists(filepath):

         fu = FileUtility()

         filepath = fu.CENIT_LOGO_FOLDER + "\\" + self.__headerLogo

      if exists(filepath):

         hpos = 140

        if portrLands == "L":

            hpos = 200

        self.image(filepath, 10, 60, 100)



Previous
Page précédente
Chapter
Page principale du chapitre
Next
Page suivante