Enable PDF output format (port of upstream PR #367)

GraphViz natively supports PDF rendering, so this just adds "pdf" to
the allowed format list and exposes it via the -f P CLI flag.
This commit is contained in:
Ryan Malloy 2026-02-13 00:25:29 -07:00
parent 26b80f7a0b
commit d8260b3fde
2 changed files with 3 additions and 6 deletions

View File

@ -19,7 +19,7 @@ format_codes = {
"g": "gv", "g": "gv",
"h": "html", "h": "html",
"p": "png", "p": "png",
# "P": "pdf", # TODO: support PDF "P": "pdf",
"s": "svg", "s": "svg",
"t": "tsv", "t": "tsv",
} }

View File

@ -440,7 +440,7 @@ class Harness:
# graphical output # graphical output
graph = self.graph graph = self.graph
for f in fmt: for f in fmt:
if f in ("png", "svg", "html"): if f in ("png", "svg", "html", "pdf"):
if f == "html": # if HTML format is specified, if f == "html": # if HTML format is specified,
f = "svg" # generate SVG for embedding into HTML f = "svg" # generate SVG for embedding into HTML
# SVG file will be renamed/deleted later # SVG file will be renamed/deleted later
@ -471,10 +471,7 @@ class Harness:
# HTML output # HTML output
if "html" in fmt: if "html" in fmt:
generate_html_output(filename, bomlist, self.metadata, self.options) generate_html_output(filename, bomlist, self.metadata, self.options)
# PDF output # PDF output is handled by GraphViz in the format loop above
if "pdf" in fmt:
# TODO: implement PDF output
print("PDF output is not yet supported")
# delete SVG if not needed # delete SVG if not needed
if "html" in fmt and not "svg" in fmt: if "html" in fmt and not "svg" in fmt:
# SVG file was just needed to generate HTML # SVG file was just needed to generate HTML