We're using cookies to make this site more secure, featureful and efficient.

Issue 2630: Groundhog Day Kargapoltsev Diagram Korobeynikov SCDDB 14989 20211009

Object
Groundhog Day (Dance)
Submitter
Peter Meier Zurich
Assigned to
Anselm Lingnau
Priority
Normal
Disposition
Fixed
Description

Thank you very much for your contribution to SCDDB.

Crib Diagram comment button error “page not found”

PDF file of the diagram shows rubbish. Only on my computer?

Kindest regards

Peter Meier Zurich tpsm051029@yahoo.de

Previous Actions

  • Date  Oct. 9, 2021, 1:28 p.m.
  • User  Unknown

New issue submitted

  • Date  Oct. 9, 2021, 1:42 p.m.
  • User  Murrough Landon (murrough)

Assigned changed to »akorobeynikov« (previously »None«)
Disposition changed to »Accepted« (previously »New«)

Hello Peter,
Yes, unfortunately the correction to diagram button has not worked for a long time. Its on Anselm’s to do list for the next software version…

I agree there is a problem. In both Firefox and Chrome if I try to download the diagram I see “Not supported by viewer” all over the image for both the PDF and PNG versions. The SVG is OK. Thats what the website uses by default.

So I am assigning this to Anton in case there is something in his diagram. But I think the conversions to PDF and PNG may be made by Anselm’s software in which case it would only be fixable by him.

Anton, this might be a more general problem. I remembered that Anastasia Solodyankina made a diagram for Rubik’s Cube (https://my.strathspey.org/dd/dance/18219/#cribs) using your tool and that also exhibits the same behaviour.
Cheers, Murrough

  • Date  Oct. 9, 2021, 1:57 p.m.
  • User  Anton Korobeynikov (akorobeynikov)

Yes, unfortunately, there is a problem with SVG => PDF / PNG converter as it only supports a subset of SVG features. There are 2 ways to fix the issue:

  • Fix the converter
  • Fix the SVG producer

I believe I know how to do the latter, however, I’m not 100% as it’s mostly try-and-error process to be bug per bug compatible. Sadly, this would require to re-draw all the produced diagrams and this is something that prevented me from doing this…

That said, I do not have a satisfactory solution for this problem at this moment. If only PDF is required, then one could use “Print to PDF” option in e.g. Chrome. This certainly won’t solve the problem if the diagram is e.g. embedded into some dance list.

  • Date  Oct. 9, 2021, 6:47 p.m.
  • User  Anselm Lingnau (anselm)

Assigned changed to »anselm« (previously »akorobeynikov«)

The SVG-to-PDF converter (rsvg) is pretty good but obviously not perfect. I’ll have a look to see whether there’s a newer version available and whether that will work.

We require diagrams to be in SVG format because SVG is scalable, works reasonably well with most browsers, and can straightforwardly be converted into other formats (except when it can’t). Generally one would expect the requirements of SCD line diagrams to not exercise the dark corners of the SVG standard, but who knows what graphics programs will do when they’re asked to produce SVG.

  • Date  Oct. 10, 2021, 11:26 p.m.
  • User  Anton Korobeynikov (akorobeynikov)

@anselm: It came to my great surprise to realize that rsvg does not support many SVG features :) As far as I can see, the big category of these unsupported features is connected with the text rendering. From the producer standpoint it’s much easier to mark that the text in the box is e.g. right-justified and let the renderer does it’s magic rather than calculate the precise position of text start by hands given the font, font size, etc. Note that SVG allows the inclusion of arbitrary HTML and CSS styles. And apparently, this is not something rsvg is good in :) Maybe upgrade will help, but locally I do have 2.50.7 and it does not render it properly.

I need to think how to “fix” this at producer side…

  • Date  Oct. 11, 2021, 12:43 a.m.
  • User  Murrough Landon (murrough)

For my curiousity I had a quick look and the general advice seems to be if you want to render SVG as PDF/PNG then avoid use of the SVG “foreignObject” elements using non-SVG code such as HTML.

Anton, you mentioned “all the produced diagrams” suggesting you had created several of them. However in https://my.strathspey.org/dd/cribsource/9/#diagrams there is only the one diagram (for Groundhog Day). Did you make others but not upload them to SCDDB?

Although it seemed a nice idea to base your asl.github.io/scd-diagrammer tool on draw.io I just checked and that also likes to save text boxes as foreignObjects. In my one test of scd-diagrammer a couple of years ago I saved a PNG directly and that was fine. Its just the SVG from draw.io that cannot later be converted to PNG/PDF.

  • Date  Oct. 11, 2021, 8:41 a.m.
  • User  Anton Korobeynikov (akorobeynikov)

Murrough,

Yes. Unfortunately we cannot control whether draw.io engine creates such SVG objects. Empirically it seems that one should restrain from the use of almost all text rendering options (and this is expected since SVG has very basic text built-in text rendering options). And… for SCD Diagrammer this means that all built-in libraries should be redone and the changes to UI introduced in order to warn the users from using certain features. I need to find some time to revamp it, add new features, etc. also having compatibility with SCDDB in mind.

I made few dozen diagrams, some of them (including the Groundhog Day) could be opened as examples in SCD Diagrammer. I decided not to upload them to SCDDB until the issue with SVG rendering fixed one way or another. As far as I know, others also produced diagrams in SCD Diagrammer :)

  • Date  Oct. 12, 2021, 7:40 p.m.
  • User  Anselm Lingnau (anselm)

It turns out that Google Chrome does a pretty good batch SVG-to-PDF conversion if you’re running it “headless” (see, e.g., https://gist.github.com/s417-lama/84bf66de1096c4587e8187092fb41684). I’m not entirely sure that this is the best approach for a server-side application, though – it’s a bit on the heavy side and should probably run in some sort of sandbox or container for security.

It might be worth doing an automated SVG-to-PDF conversion using headless Chrome when the diagram is uploaded to the server (possibly only for crib sources where the SVG is known to break rsvg-convert; I’m looking at you, Anton …) so we have a known-good PDF when we need it. Or we could simply ask the Antons of this world to do it themselves and upload both SVG and PDF … Doing PDF-to-PNG at various resolutions shouldn’t be a huge problem using pngtoppm from poppler-utils or something like that, and we could do that in preference to using rsvg-convert if a PDF exists on the server.

  • Date  Oct. 12, 2021, 9:51 p.m.
  • User  Anton Korobeynikov (akorobeynikov)

Anselm,

I believe I saw more or less end-to-end solution on top of Chrome engine packed into a tool. Let me remember what it was and return to you.

  • Date  Dec. 12, 2021, noon
  • User  Anton Korobeynikov (akorobeynikov)

Anselm,

Finally I was able to remember. Here we go: https://wkhtmltopdf.org/

  • Date  Jan. 19, 2023, 9:19 p.m.
  • User  Viktor Lehmann (tone2tone)

One problem might arise when there is a font included in the SVG file and this special font cannot be interpretated by the browser. Just a guess. I mostly vectorise all fonts before exporting SVG. I might be able to double check this for you - send me your SVG file as is - I will open it, vectorise the fonts, export it again with my illustrator software and send it back. As an alternative, you get yourself “Inkscape” (a freeware alternative to Illustrator) where you could rework the svg and export it again by yourself. Requires a bit of initial work to get along with the programme, but produces good standard SVGs as it is all based on that format for this application.

  • Date  Jan. 20, 2023, 11:19 a.m.
  • User  Anton Korobeynikov (akorobeynikov)

Viktor,

There are no embedded fonts. And Inkscape is having the similar issues interpreting these SVGs as it is using the same SVG handling engine. Sadly, SVGs are not quite standard as they allow lots of extensions because some features (in particular font rendering) is quite basic in the “standard” SVGs.

  • Date  Aug. 16, 2023, 1:12 p.m.
  • User  Anselm Lingnau (anselm)

Disposition changed to “Fixed” (previously “Accepted”)

The diagram now seems to be in the database. (I fixed the usual scalability problem by hand in the SVG element.) Closing this issue (and issue 2631) as “fixed”.