Skip to content

Commit

Permalink
Add custom PDF banner with logo using importlib.resources
Browse files Browse the repository at this point in the history
  • Loading branch information
cdot65 committed Feb 4, 2024
1 parent 2651132 commit 998cf0a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pan_os_upgrade/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@


# standard library imports
import importlib.resources as pkg_resources
import ipaddress
import json
import logging
Expand Down Expand Up @@ -2969,11 +2970,13 @@ def generate_diff_report_pdf(
content = []
styles = getSampleStyleSheet()

# Custom Banner with Logo and Styling
logo = "assets/logo.png"
img = Image(logo, width=71, height=51)
img.hAlign = "LEFT"
content.append(img)
# Accessing logo.png using importlib.resources, creating a custom banner with logo and styling
with pkg_resources.files("pan_os_upgrade.assets").joinpath("logo.png") as logo_path:
img = Image(
str(logo_path), width=71, height=51
) # Convert Traversable object to string for Image path
img.hAlign = "LEFT"
content.append(img)

banner_style = styles["Title"]
banner_style.fontSize = 24
Expand Down

0 comments on commit 998cf0a

Please sign in to comment.