[Feature Request] Creation of the Template as FreeCAD object

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
tobiasfalk
Posts: 93
Joined: Fri Feb 05, 2021 2:35 pm

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by tobiasfalk »

The workaround with exporting as SVG and the converting in to PDF is a nice solution and I agree this seams like the Best way to fix the PDF exported problem. Why I create this withe the Titel of
Creation of the Template as FreeCAD object
was becais this would be the best and nicest way to solve the Problem. The reason why I mentioned KiCAD templates was becaus I thoughed it would be a nice incloution to FreeCAD, this is becaus it wouöd br easy to have one template formate for both of the Programs.
Laurie Hartley
Posts: 522
Joined: Mon Feb 27, 2017 5:33 am
Location: Australia

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by Laurie Hartley »

bensay wrote: Fri Aug 05, 2022 7:09 pm - While InkScape (to some users) can be difficult to use,
:lol: Guilty as charged :lol: .
User avatar
bensay
Posts: 202
Joined: Wed Dec 22, 2021 8:14 pm
Location: Danmark
Contact:

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by bensay »

tobiasfalk wrote: Fri Aug 05, 2022 8:46 pm The workaround with exporting as SVG and the converting in to PDF is a nice solution and I agree this seams like the Best way to fix the PDF exported problem. Why I create this withe the Titel of
Creation of the Template as FreeCAD object
was becais this would be the best and nicest way to solve the Problem. The reason why I mentioned KiCAD templates was becaus I thoughed it would be a nice incloution to FreeCAD, this is becaus it wouöd br easy to have one template formate for both of the Programs.
You're right that if templates needed to be made as FreeCAD objects, KiCad style would be an option to save these templates as FreeCAD objects would have limited features.
User avatar
FBXL5
Posts: 979
Joined: Sat Aug 03, 2019 8:45 pm

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by FBXL5 »

I still don't get it.
To use an embedded svg file as a background to draw on seems to be a clever solution.
Once created there is hardly any need to alter a template (except the usual editable texts).

Why is it important to have texts as text objects and not geometric objects?
A drawing is a collection of data (model data, description data, dinensioning data...) and not a source.
Why would someone want to extrakt derived information from a drawing instead of the original from the drawing's sources?
For readable data you can use barcode or a more modern variant.

If you use text objects with unusual fonts it can lead to unwanted results when the drawing is rendered for printing. A missing font wil be replaced with a standart font (that hopefully contains all used special characters) and deforms the perfectly arranged text blocks.
But you seem to want to render it as pdf to avoid these problems...

A drawing is a contract (or at least a part of it) and each dimension or annotation is a paragraph of this contract. No one wants an altered contract due to font incompatibillities.
And so graphic elements on a drawing make more sense to me than text objects.
User avatar
bensay
Posts: 202
Joined: Wed Dec 22, 2021 8:14 pm
Location: Danmark
Contact:

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by bensay »

FBXL5 wrote: Sat Aug 06, 2022 4:33 pm I still don't get it.
I am a bit unsure what you mean and what you don't get? I am assuming, that you don't have some background information about the issue - let me know if I am wrong.

The template/background of a Page is currently made by loading an SVG file onto the TechDraw Page, example: https://github.com/FreeCAD/FreeCAD/blob ... 00_Pep.svg. This contains information about the drawing such as page number, author, description and also make up the borders of the page.

It is Qt (3rd party library) that handles the template SVG together with all the other TechDraw objects such as View, Dimensions and Annotations.

Then, when the users are finished with the drawing, they most probably want to export this TechDraw Page (containing the template from SVG, views, dimensions and annotations). The exporting of a PDF is made by a build-in function of Qt (3rd party library) - but it has a fatal flaw: what is text in the SVG gets converted to path in the PDF.

So what does this mean? Well in the PDF, the text from the SVG isn't anymore made by "real letters" as we know them, but is instead drawn as a figure having the same shape as the letters. (This might be known to some people as text to path as I call it. In InkScape, you can use the Object to Path function if you want to play around and see the difference between real text and path text.) And because this text in the SVG isn't real text anymore, but just path text, it means that it isn't markable and it isn't searchable.

This is nuisance to the user and makes up the issue that is talked about in this thread. But then - how does this make up the background of the thread about converting to FreeCAD objects?

Earlier, I only wrote that the template of SVG gets its text convert to path. This is because the fatal flaw only applies to objects loaded in as SVG (ref. QGraphicsSvgItem). That is also why the text that is not a part of the template (made from SVG) - such as annotations, dimensions and etc. does not get converted to path text but still is real text. This is because annotations, dimensions and etc. is drawn as FreeCAD object (QGraphicsItems made from bottom not involving importing any SVG).

And here we get to the proposal made in the initial post in the thread: convert the template to FreeCAD objects. If the template is made as FreeCAD objects and not as imported SVG, then the text in the template won't get converted to path but will still remain real text. Now, there aren't any issue with unmarkable or unsearchable text anymore.

That is why you would want the template to be made as text objects and not as an imported SVG object. It doesn't have anything to do with fonts or similar, but that the PDF rendering from the Qt (3rd party library) as a fatal flaw, nuisance to the user. Rendering to PDF is not to avoid any problem: rendering to PDF is the issue itself as it contains the fatal flaw: unmarkable and unsearchable text. There is no such thing as font incompatibility related to the issue.

For everyone who wants to dive more into this issue as developers:
- Text gets converted to path if SVG imported as a QGraphicsSvgItem is rendered with a QPainter.
- Text doesn't get converted to path if made as QGraphicsItems made from scratch.
- The rendering is done by QGraphicsScene::render (https://doc.qt.io/qt-6/qgraphicsscene.html#render) or QGraphicsView::render (https://doc.qt.io/qt-6/qgraphicsview.html#render) (I don't remember which).
- In source code, the rendering for PDF is done here https://github.com/FreeCAD/FreeCAD/blob ... #L674-L835
- In source code, the rendering for SVG is done here https://github.com/FreeCAD/FreeCAD/blob ... #L692-L768
- In source code, the workaround for SVG is implemented here https://github.com/FreeCAD/FreeCAD/blob ... #L731-L739 and here https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L767
- The rendered SVG doesn't convert text to path because the above workaround has been implemented. The workaround works by hiding the template (made from SVG) from rendering and then adding it manually again (since we already got the SVG source)
- If the code inside FreeCAD is too complicated to wrap your head around, then a short simplified demo of the issue is made here https://stackoverflow.com/questions/732 ... d-not-text. I also made a repository on https://github.com/benj5378/QGraphicsSv ... nder-issue with build instructions if you want to play with the code

I hope this clears things up a bit.
User avatar
FBXL5
Posts: 979
Joined: Sat Aug 03, 2019 8:45 pm

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by FBXL5 »

bensay wrote: Sat Aug 06, 2022 6:55 pm the fatal flaw: unmarkable and unsearchable text.
Thanks for the explanation.

I still do not see why I could need markable or searchable texts in a drawing template or its derived pdf file.

Creating a drawing without the need to use svg templates could be indeed an improvement but for other reasons.
User avatar
bensay
Posts: 202
Joined: Wed Dec 22, 2021 8:14 pm
Location: Danmark
Contact:

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by bensay »

FBXL5 wrote: Sat Aug 06, 2022 10:36 pm I still do not see why I could need markable or searchable texts in a drawing template or its derived pdf file.
That is up to the fanrasy to imagine some use cases. Maybe we got a big PDF file with lots of pages containing different parts and we would like to search for the part name given in the title of the template. Maybe the parts defined in the PDF has to send it to another person putting it into a database and copyable text is needed.

There could be multiple cases... But most of them are probably pretty unlikely to the majority of FreeCAD users.
FBXL5 wrote: Sat Aug 06, 2022 10:36 pm Creating a drawing without the need to use svg templates could be indeed an improvement but for other reasons.
Which other reasons?
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by chrisb »

I can think of quite some use cases where searching in exported PDFs can be helpful, especially when using a tool to search over a lot of documents. Title, author, assembly, even date (it hasn't to be the file's timestamp) and scale of a drawing can be sensible subjects to searching.
Beyond that it may be of interest to use basic items such as characters and the strings made from them rather than something complicated as the contour of a string.

It is a valid argument though that some characters may not be available. This would be even more serious for the dimensions on the drawing, which are texts too. Imagine "µm" changes to "mm". It may be sensible to provide a possibility to embed special fonts into the document.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
FBXL5
Posts: 979
Joined: Sat Aug 03, 2019 8:45 pm

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by FBXL5 »

bensay wrote: Sun Aug 07, 2022 12:17 am Maybe we got a big PDF file with lots of pages containing different parts and we would like to search for the part name given in the title of the template. Maybe the parts defined in the PDF has to send it to another person putting it into a database and copyable text is needed.
If you need to scan your pdf files for information you have a problem with the way you archieve your documents. A proper data base or PDM system would be more helpful in that case.
bensay wrote: Sun Aug 07, 2022 12:17 am Which other reasons?
To optionally use TechDraw as a proper 2D drawing workbench, for example...
User avatar
bensay
Posts: 202
Joined: Wed Dec 22, 2021 8:14 pm
Location: Danmark
Contact:

Re: [Feature Request] Creation of the Template as FreeCAD object

Post by bensay »

FBXL5 wrote: Sun Aug 07, 2022 11:44 am
bensay wrote: Sun Aug 07, 2022 12:17 am Maybe we got a big PDF file with lots of pages containing different parts and we would like to search for the part name given in the title of the template. Maybe the parts defined in the PDF has to send it to another person putting it into a database and copyable text is needed.
If you need to scan your pdf files for information you have a problem with the way you archieve your documents. A proper data base or PDM system would be more helpful in that case.
FreeCAD is for everyone to use. I might also need to search through some drawings in a very small company or as a small hobbyist. Even though a database or PDM system would be more helpful, no one should be obligated to have such systems for using FreeCAD instead of just CTRL+F their PDF document. The unmarkable-unsearchable-path-text issue still exist and I recognize it - it is just low priority to me.
FBXL5 wrote: Sun Aug 07, 2022 11:44 am
bensay wrote: Sun Aug 07, 2022 12:17 am Which other reasons?
To optionally use TechDraw as a proper 2D drawing workbench, for example...
Why would drawing the templates inside TechDraw instead of InkScape make it more of a proper 2D drawing workbench? InkScape will always have more functionality to make the custom graphics needed - having it inside TechDraw will only be a maintaining burden and take a lot of coding, just to implement some of the features that InkScape already has. TechDraw's main purpose is to offer projection, dimensioning etc. for making technical drawings that other applications don't do; it would draw focus away from the main purpose just for implementing the same features InkScape already has. This is my opinion of course. Feel free to give more examples.
Post Reply