PcbDraw icon indicating copy to clipboard operation
PcbDraw copied to clipboard

Generated SVG image is not possible to open in browsers (image is empty, white page)

Open roman-dvorak opened this issue 2 years ago • 3 comments

Hi, I am trying to generate a PCB svg image with PcbDraw plot tool. Image that could be displayed in a web browser.

The image that I generate using the command pcbdraw plot file.kicad_pcb plot.svg I am able to open in some image viewers including, for example, inkscape. When I open the file in a browser, I see a blank (all white) page. If I view the source code in the browser, I see the entire XML there.

If I create an SVG image in the inkscape and open it in the browser, the browser will open it without any problems.

There will probably be a problem with some svg tag. But I can't figure out which it could be. We tried it in ubuntu 21.04, with current firefox and chromium (the same result).

Is this condition known or is it a mistake?

roman-dvorak avatar Jun 05 '22 11:06 roman-dvorak

It's probably as issue of the way KiCAD exports SVGs where the numbers are too high and browsers does not support them.

See https://gitlab.com/kicad/code/kicad/-/issues/10569, https://gitlab.com/kicad/code/kicad/-/issues/9976, and https://gitlab.com/kicad/code/kicad/-/issues/9447

Electro707 avatar Jun 05 '22 20:06 Electro707

Yes, this is just like Electro707 says. I attempted to convert the units, however, it requires fully parsing and interpreting the geometry in SVG file and it seemed like too much work with a lot of corner cases, so it is not included in the current version. However, we might give it another shot.

yaqwsx avatar Jun 06 '22 05:06 yaqwsx

Thank you for clarification!

roman-dvorak avatar Jun 07 '22 06:06 roman-dvorak

Hi @yaqwsx !

I attempted to convert the units

Not really necesary. You can just change the SVG precision used by KiCad. Just going from 6 (default) to 5 fixes the problem. I'm using 4 to allow using really big page sizes.

Here you can see how I patched PcbDraw code to use a configurable precision: https://github.com/INTI-CMNB/KiBot/commit/417dbadcd2e0a7a6bf3c9a4b936532f85530ad77#diff-a3084f061bd46974faf8029e89b48d6c0ce04f85da549c1504d13710e13bfc00

set-soft avatar Oct 21 '22 16:10 set-soft

@set-soft: Thank you for finding that out and letting me know. This is great news! I implemented the required changes in 22a9472.

yaqwsx avatar Oct 24 '22 13:10 yaqwsx