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",
"h": "html",
"p": "png",
# "P": "pdf", # TODO: support PDF
"P": "pdf",
"s": "svg",
"t": "tsv",
}

View File

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