(SOLVED) "Fit page to selection" bug with imported SVG?

This is NOT a support forum. You are welcome to discuss software issues here, but all issues should be reported on Launchpad if you want them fixed.
Horus
Posts: 14
Joined: Mon Apr 21, 2008 11:24 pm

(SOLVED) "Fit page to selection" bug with imported SVG?

Postby Horus » Tue Apr 22, 2008 1:56 am

Before posting this as a bug report, I'd like to get confirmation from this forum first that this is indeed a bug. But if anybody wants to report the bug in my behalf, you're most welcome.

I'm working under WinXP¨Pro.

I had my company logo in an EPS file (ie it's a vector graph). I exported it to SVG using GSView. I then opened it in InkScape. But whenever I open File > Document Properties > press "Fit page to selection" button, the image is resized!

I first thought it might come from my EPS file which might not comply to EPS standard, but I managed to reproduce this with other EPS/PS files. Here are the steps:

1. Install GhostScript, GSView and PStoEdit plugins. I'm using versions 8.6, 4.9 and 3.45 respectively, but previous versions should be sufficient to show this bug.

2. Open the snowflak.ps file (normally it's in C:\Program Files\gs\gs8.60\examples)

3. Convert it to SVG:
Open Edit > Convert to vector format > choose "plot-svg: ....".
I only checked "Map to ISO-Latin1" option but I don't think this would change anything.

4. Give it any name and save as SVG.
At this point, you could open the SVG file in Firefox to see that it can't be rendered normally.

5. Open the SVG in Inkscape to see that it's drawn correctly. But the document size is normally smaller than the whole picture. DON'T change anything and save again (use Save as to force the saving).
Open the SVG in Firefox to see that it can be rendered, but the upper and lower parts are trimmed!

6. Back to Inskscape, ungroup that group of 6 snowflakes, and delete some snowflakes.
Eg, delete the lower four of them to leave the upper 2 snowflakes side by side.
Regroup them if you like, but this isn't necessary.

7. Open File > Document properties, then press "Fit page to selection" and you should see that both snowflakes are resized and become smaller!
Well, this isn't all. If you save it and open in Firefox, you could see that the snowflakes are deformed!
____

So, could someone reproduce this? Did I do something wrong? Any workaround?
Last edited by Horus on Tue Nov 22, 2011 2:46 am, edited 1 time in total.

User avatar
capnhud
Posts: 435
Joined: Mon Jun 04, 2007 8:30 pm
Location: U.S.A

Re: "Fit page to selection" bug with imported SVG?

Postby capnhud » Tue Apr 22, 2008 3:49 am

No not quite sure what is going wrong with that approach but the same thing happened to me. You would probably be better off to use the convert to vector format and choose .pdf (adobe.....) and then open inkscape and drop the .pdf file in open document and then fit page to selection and then file save as svg.

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: "Fit page to selection" bug with imported SVG?

Postby sas » Tue Apr 22, 2008 5:06 am

Presumably the SVG files produced by pstoedit have a viewBox attribute. Inkscape currently has lots of problems with viewBox attributes, and being unable to fit page to selection is one of them.

A workaround is to remove the viewBox attribute: open the XML editor (Shift+Ctrl+X), click on the root svg:svg element in the left pane, click on the viewBox attribute in the right pane, then click the icon at the top to delete the attribute.

User avatar
capnhud
Posts: 435
Joined: Mon Jun 04, 2007 8:30 pm
Location: U.S.A

Re: "Fit page to selection" bug with imported SVG?

Postby capnhud » Tue Apr 22, 2008 7:28 am

A workaround is to remove the viewBox attribute


Even though the viewbox attribute is removed from the eps files I convert with that method (ie Ghostscript then remove viewbox) do not turn out well at all when you try to convert to svg. I believe it was the author's (pstoedit) way of getting you to get the shareware plugin you need to actually convert to svg.

Converting to .pdf and then open in inkscape has typically been the best solution it seems to preserve the eps file much better than converting svg through GNUplot.

Horus
Posts: 14
Joined: Mon Apr 21, 2008 11:24 pm

Re: "Fit page to selection" bug with imported SVG?

Postby Horus » Tue Apr 22, 2008 8:27 pm

sas wrote:A workaround is to remove the viewBox attribute: open the XML editor (Shift+Ctrl+X), click on the root svg:svg element in the left pane, click on the viewBox attribute in the right pane, then click the icon at the top to delete the attribute.


This doesn't work for me either.

I click on the svg:svg element, and as soon as I delete the viewBox attribute, everything disappears and there's only a blank document :shock:
No more snowflake!

I've tried with my company logo, started from EPS file all again, and I also have this problem if I delete the viewBox attribute.

PS: I'm using Inkscape 0.46

User avatar
capnhud
Posts: 435
Joined: Mon Jun 04, 2007 8:30 pm
Location: U.S.A

Re: "Fit page to selection" bug with imported SVG?

Postby capnhud » Tue Apr 22, 2008 9:00 pm

When I use ghostscript I convert eps files to .pdf and then open the.pdf in inkscape. Once you have done this you can then "fit page to selection".

Eliminating the viewbox attribute does work, but you will find that you must do Edit>Select all to even find the graphic on the page because it is gonna be really small.

Horus
Posts: 14
Joined: Mon Apr 21, 2008 11:24 pm

Re: "Fit page to selection" bug with imported SVG?

Postby Horus » Tue Apr 22, 2008 9:16 pm

Yes! Using PDF as an intermediary format is the solution!

I didn't know Inkscape could open PDF.

User avatar
capnhud
Posts: 435
Joined: Mon Jun 04, 2007 8:30 pm
Location: U.S.A

Re: "Fit page to selection" bug with imported SVG?

Postby capnhud » Tue Apr 22, 2008 9:19 pm

Yes that is one of the new features of .46

Horus
Posts: 14
Joined: Mon Apr 21, 2008 11:24 pm

Re: "Fit page to selection" bug with imported SVG?

Postby Horus » Tue Apr 22, 2008 10:18 pm

So, do I need to post a bug? Or the problem is related to another cause?

Horus
Posts: 14
Joined: Mon Apr 21, 2008 11:24 pm

Re: "Fit page to selection" bug with imported SVG?

Postby Horus » Tue Apr 22, 2008 10:22 pm

capnhud wrote:Eliminating the viewbox attribute does work, but you will find that you must do Edit>Select all to even find the graphic on the page because it is gonna be really small.

Yeah, you're right. The graphic has become ridiculously small. I have to zoom to 1000% but I could barely see a small point! :?

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: "Fit page to selection" bug with imported SVG?

Postby sas » Wed Apr 23, 2008 1:43 am

Horus wrote:So, do I need to post a bug? Or the problem is related to another cause?

The problem of "fit page to selection" not working with viewBox has already been reported.

The problem of pstoedit not being a good way to convert EPS to SVG is already known, and I think 0.47 will instead go via PDF (using Ghostscript's ps2pdf, just as capnhud has suggested).

So you don't need to post a bug report.

Horus
Posts: 14
Joined: Mon Apr 21, 2008 11:24 pm

(SOLVED) "Fit page to selection" bug with imported SVG?

Postby Horus » Tue Nov 22, 2011 2:46 am

Hi,

I'm coming back to this bug, but this time I'm using Inkscape 0.48.2 r9819. I went through the steps I had written before but this time, the result of step 7 is different: it works! :D Things are not resized nor are they deformed. And I don't even need to use PDF as an intermediate format :D

Well, actually, inside the SVG drawing area, there's a transparent box (is that the viewbox?) fitted to the same size as the "suggested document size". If this transparent box is left as it is, "Resize page to drawing or selection" function would leave a lot of empty space under the snowflakes in final SVG. We just need to manually delete this transparent box before clicking on the "Resize page to drawing or selection" button and voilà!

Fantastic! :D


Return to “Discuss Software Issues”