wireviz / WireViz

Easily document cables and wiring harnesses.
GNU General Public License v3.0
4.4k stars 223 forks source link

[Feature Request] Adding PDF as output #354

Open tobiasfalk opened 5 months ago

tobiasfalk commented 5 months ago

We may already have SVG as a vector graphics output, but it still would be nice if PDF would also be available.

martinrieder commented 5 months ago

This has been in development for some time. Check #32 and the associated feature branch. The new CLI offers a switch to request PDF output format, but it is not implemented yet.

I noticed your repo https://github.com/tobiasfalk/KiCAD-FreeCAD-TechDraw-Template-Generator. It seems that you have some experience in that area. Feel free to contribute to #304 as well. ^^

tobiasfalk commented 5 months ago

@martinrieder I took a look at #32 and #304, and I am a bit confused, is it now possible to draw the wiring plan in to a drawing frame with title block or not, if yes how, since there is no mention I found in the doc or examples. If the whole drawing frame with title block inclusion is not stated or though out I would recommend using an already existing template format, like the FreeCAD SVG, this would bring the benefit that there are already some templates existing and that in its base form it is just an SVG that can be rendered normally. In that the fields that are meant to be edited have the XML attribute freecad:editable with a variable name and some like the title or the author/creator have the additional attribute freecad:autofill with a specified value in it to identified what it is (FreeCAD #13005 and #13790). With these ids the text that is in them can be changed before handing the template/svg over to the drawing engine to use.

When it comes to coding I would polity decline, since I not only do not really have too much experience with Python and especially not with graphvis (even when the issues I opened in the last view day would sugset otherwise I never used graphviz before that). What I am happily do is help with question where I can and with ideas on improving things.

kvid commented 5 months ago

Take a look at demo02

martinrieder commented 5 months ago

@kvid I was thinking of something like #227. The table that is contained in the HTML output of Demo02 could well be implemented in a GV node.

@tobiasfalk there are many ways that the frame and title blocks could be drawn. What do you suggest? Only add it for "printable" formats like PDF?

I do not consider HTML to be truly printable, though it should be possible to convert it into PDF.

tobiasfalk commented 5 months ago

@tobiasfalk there are many ways that the frame and title blocks could be drawn. What do you suggest? Only add it for "printable" formats like PDF?

I would add it to all Formats, since the user may want to use it in Programs like word where imprting a PDF as a page is not possible(theoretically yes but I have tried for weeks and was not able to do it). So giving the user the ability to export this as a PNG with tilteblock is defenetly a good idea, has also the benefit of being able to use it in issues and not rely on the reader to open a link to a file or so.

I do not have the ability to do something for a while(not at home), but could one of you try to import one SVG from the FreeCAD templates as image in the background?

tobiasfalk commented 5 months ago

Take a look at demo02

If I see this correctly, you are drawing this frame amd titleblock internally, wich is cald by the template tag. This limits the user to only the templates that are integrated in to WireViz, so to get a new formate that the user wants he needs to program it in to wireviz.

I would recommend a external template file formate, like svg and maybe even freecad svgs since there a lot of work is already done and for users that use both it reduces work

kvid commented 5 months ago

@tobiasfalk wrote:

Take a look at demo02

If I see this correctly, you are drawing this frame amd titleblock internally, wich is cald by the template tag. This limits the user to only the templates that are integrated in to WireViz, so to get a new formate that the user wants he needs to program it in to wireviz.

No, the HTML template might also be located at the same folder as any YAML source. In addition, the template might be specified with a relative or absolute path.

I would recommend a external template file formate, like svg and maybe even freecad svgs since there a lot of work is already done and for users that use both it reduces work

I agree, there are different existing template solutions available (including other HTML based templates), but currently, an internal HTML template format is implemented. Other suggestions are welcome, and I encourage you to describe some criteria we should aim for to enable comparing different alternatives.

martinrieder commented 4 months ago

I do not have the ability to do something for a while(not at home), but could one of you try to import one SVG from the FreeCAD templates as image in the background?

Merging two SVG files seems like a simple task. Converting this into PDF can be solved with other tools.

I would reverse the process and feed HTML into Graphviz. If you put this into a graph that only contains a single node, you can use it as a tool for SVG conversion.

By putting the BOM table into a dedicated node on the WireViz output, it could also assure that this does not overlap with the graph. Positioning and scaling might be an issue though.

Do you know if it is possible to predefine a container or an anchor in some SVG template files that could be used for merging?

tobiasfalk commented 4 months ago

https://forum.graphviz.org/t/background-image-frame-for-the-graph/2232

martinrieder commented 3 months ago

I would reverse the process and feed HTML into Graphviz. If you put this into a graph that only contains a single node, you can use it as a tool for SVG conversion. By putting the BOM table into a dedicated node on the WireViz output, it could also assure that this does not overlap with the graph. Positioning and scaling might be an issue though.

As a PoC, I manually created the .gv files to render the HTML tables using Graphviz dot into SVG files. Note that it can also render those into xdot format.

Demo02 GV BOM

```dot graph { BOM [margin=0 fontname="Arial" fillcolor="#FFFFFF" shape=box style=filled label=<

12 Wire, 0.14 mm², YE 0.6 m W1, W2
11 Wire, 0.14 mm², VT 0.3 m W3
10 Wire, 0.14 mm², RD 0.6 m W1, W2
9 Wire, 0.14 mm², OG 0.3 m W3
8 Wire, 0.14 mm², GN 0.6 m W1, W2
7 Wire, 0.14 mm², BU 0.3 m W3
6 Wire, 0.14 mm², BK 0.9 m W1, W2, W3
5 Connector, Molex KK 254, female, 8 pins 1 X1
4 Connector, Molex KK 254, female, 5 pins 1 X4
3 Connector, Molex KK 254, female, 4 pins 2 X2, X3
2 Connector, Crimp ferrule, 0.25 mm², YE 2
1 Cable, 2 x 0.25 mm² 0.3 m W4
Id Description Qty Unit Designators
>] } ```

Demo02 GV Title Block

```dot graph { BOM [margin=0 fontname="Arial" fillcolor="#FFFFFF" shape=box style=filled label=<

Date Name WireViz Demo 2
Created 2020-05-20 D. Rojas
Approved 2020-05-20 D. Rojas
WV-DEMO-02 Sheet
1
A WireViz 0.2 release 2020-10-17 D. Rojas of 1
Rev Changelog Date Name
>] } ```