Creating PDF Reports

Requirements

In order to use Pynite’s reporting features you’ll need to install the following packages. These requirements only need to be installed if you plan on using the reporting features:

  • PDFKit - PDFKit converts HTML files to PDF files via wkhtmltopdf (see discussion on wkhtmltopdf below).

  • Jinja2 - Jinja2 is a templating engine used for creating HTML files using Python.

You’ll also need to install wkhtmltopdf, which is a program, rather than a Python library. Installers for various operating systems can be freely downloaded here: download wkhtmltopdf.

Configuring wkhtmltopdf on Windows

Once wkhtmltopdf is installed, you’ll need to set your environment PATH variable to include the path to wkhtmltopdf.exe. This step ensures PDFKit can find and use wkhtmltopdf. On Windows this can generally be done by going to Control Panel -> System & Security -> System -> Advanced System Settings -> Environment Variables. On Windows 10 you can also just type “env” in the search bar to bring it up.

From there you can edit the “Path” variable to include the file path to the folder containing wkhtmltopdf.exe. The path you need to add will most likely be “C:\Program Files\wkhtmltopdf\bin” or something similar, depending on where you installed it.

Configuring wkhtmltopdf on Other Operating Systems

I’ve only ever done this for Windows, so for other operating systems I recommend going to the PDFKit documentation on PyPI here: PDFKit on PyPI. It explains PKFKit configuration options that “should” work, thought I’ve never done it myself. Good luck!

Generating & Customizing Reports

Generate reports by importing the Reporting module and then calling the create_report method. By default, the report prints everything, but it can be customized by setting the various keyword arguments in the create_report method to False. Also by default, the PDF report is saved in the Pynite folder unless another filepath is specified using the output_filepath argument.

Syntax:

create_report(model, output_filepath='.//PyNite Report.pdf', nodes=True,
              members=True, plates=True, member_releases=True,
              node_reactions=True, node_displacements=True,
              member_end_forces=True, member_internal_forces=True,
              plate_corner_forces=True, plate_center_forces=True,
              plate_corner_membrane=True, plate_center_membrane=True)

Example:

# Import the reporting module
from PyNite import Reporting

# Create the report
Reporting.create_report(my_model, output_filepath='./My Report.pdf')

Reporting Class Reference

PyNite.Reporting.create_report(model, output_filepath=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/pynite/checkouts/stable/PyNite/Pynite Report.pdf'), **kwargs)

Creates a pdf report for a given finite element model.

Parameters:
  • model (FEModel3D) – The model to generate the report for.

  • output_filepath (str, optional) – The filepath to send the report to. Defaults to ‘Pynite Report.pdf’ in your PYTHONPATH

  • **kwargs – See below for a list of valid arguments.

Keyword Arguments:
  • node_table (bool) – Set to True if you want node data included in the report. Defaults to True.

  • member_table (bool) – Set to True if you want member data included in the report. Defaults to True.

  • member_releases (bool) – Set to True if you want member end release data included in the report. Defaults to True.

  • plate_table (bool) – Set to True if you want plate/quad data included in the report. Defaults to ``True.

  • node_reactions (bool) – Set to True if you want node reactions included in the report. Defaults to True

  • node_displacements (bool) – Set to True if you want node displacement results included in the report. Defaults to True.

  • member_end_forces (bool) – Set to True if you want member end force results included in the report. Defaults to True.

  • member_internal_forces (bool) – Set to True if you want member internal force results included in the report. Defaults to True

  • plate_corner_forces (bool) – Set to True if you want plate/quad corner force results (out-of-plane/bending) included in the report. Defaults to True.

  • plate_center_forces (bool) – Set to True if you want plate/quad center force results (out-of-plane/bending) included in the report. Defaults to True.

  • plate_corner_membrane (bool) – Set to True if you want plate/quad corner membrane (in-plane) force results included in the report. Defaults to True.

  • plate_center_membrane (bool) – Set to True if you want plate/quad center membrane (in-plane) force results included in the report. Defaults to True.