pdf: underlying commands - no converter included
This commit is contained in:
parent
72176677f7
commit
1ecbe6d23c
@ -37,7 +37,7 @@ groups = {
|
||||
|
||||
input_extensions = [".yml"]
|
||||
extensions_not_containing_graphviz_output = [".gv", ".bom.tsv"]
|
||||
extensions_containing_graphviz_output = [".png", ".svg", ".html"]
|
||||
extensions_containing_graphviz_output = [".png", ".svg", ".html", ".pdf"]
|
||||
generated_extensions = (
|
||||
extensions_not_containing_graphviz_output + extensions_containing_graphviz_output
|
||||
)
|
||||
@ -68,7 +68,7 @@ def build_generated(groupkeys):
|
||||
try:
|
||||
res = cli([
|
||||
"--formats",
|
||||
"ghpst",
|
||||
"ghpstPb",
|
||||
str(yaml_file),
|
||||
"--prepend",
|
||||
yaml_file.parent / "metadata.yml"
|
||||
|
||||
@ -14,6 +14,7 @@ from wireviz import APP_NAME, __version__
|
||||
from wireviz.wv_bom import bom_list
|
||||
from wireviz.wv_utils import bom2tsv
|
||||
from wireviz.wv_harness_quantity import HarnessQuantity
|
||||
from wireviz.wv_output import generate_pdf_output
|
||||
|
||||
format_codes = {
|
||||
"c": "csv",
|
||||
@ -126,9 +127,11 @@ def cli(files, formats, prepend, output_dir, output_name, version, use_qty_multi
|
||||
harness = None
|
||||
shared_bom = {}
|
||||
sheet_current = 1
|
||||
output_names = []
|
||||
# run WireVIz on each input file
|
||||
for _file in files:
|
||||
_output_name = _file.stem if not output_name else output_name
|
||||
output_names.append(_output_dir / _output_name)
|
||||
|
||||
print("Input file: ", _file)
|
||||
print(
|
||||
@ -155,6 +158,9 @@ def cli(files, formats, prepend, output_dir, output_name, version, use_qty_multi
|
||||
)
|
||||
shared_bom = ret["shared_bom"]
|
||||
|
||||
if 'pdf' in output_formats and 'html' in output_formats:
|
||||
generate_pdf_output(output_names)
|
||||
|
||||
# TODO: move shared bom generation to a method?
|
||||
if "shared_bom" in output_formats:
|
||||
shared_bom_file = (_output_dir / "shared_bom").with_suffix(".tsv")
|
||||
|
||||
@ -30,7 +30,7 @@ from wireviz.wv_graphviz import (
|
||||
parse_arrow_str,
|
||||
set_dot_basics,
|
||||
)
|
||||
from wireviz.wv_output import embed_svg_images_file, generate_html_output
|
||||
from wireviz.wv_output import embed_svg_images_file, generate_html_output, generate_pdf_output
|
||||
from wireviz.wv_utils import bom2tsv
|
||||
|
||||
|
||||
@ -394,8 +394,7 @@ class Harness:
|
||||
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")
|
||||
generate_pdf_output(filename)
|
||||
# delete SVG if not needed
|
||||
if "html" in fmt and not "svg" in fmt:
|
||||
# SVG file was just needed to generate HTML
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
import base64
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import List, Union
|
||||
from typing import Dict, List, Union
|
||||
|
||||
import wireviz # for doing wireviz.__file__
|
||||
from wireviz.wv_dataclasses import Metadata, Options
|
||||
@ -56,6 +56,28 @@ def embed_svg_images_file(
|
||||
filename_out.replace(filename_in)
|
||||
|
||||
|
||||
def generate_pdf_output(
|
||||
filename_list: List[Path],
|
||||
options: Dict=None,
|
||||
):
|
||||
#options = options if options is not None else {}
|
||||
# TODO: pass intelligent options
|
||||
options = {
|
||||
'options': {
|
||||
'page-size': 'A3',
|
||||
'orientation': 'landscape',
|
||||
}
|
||||
}
|
||||
if isinstance(filename_list, Path):
|
||||
filename_list = [filename_list]
|
||||
output_path = filename_list[0].with_suffix('.pdf')
|
||||
else:
|
||||
output_dir = filename_list[0].parent
|
||||
output_path = (output_dir / output_dir.name).with_suffix('.pdf')
|
||||
|
||||
filepath_list = [f.with_suffix('.html') for f in filename_list]
|
||||
|
||||
print(f'Generating pdf output: {output_path}')
|
||||
|
||||
def generate_html_output(
|
||||
filename: Path,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user