bugGNU Octave - Bugs: bug #53197, Size of svg output is 75% of...

 
 

bug #53197: Size of svg output is 75% of PaperPosition value

Submitter:  Rik <rik5>
Submitted:  Wed 21 Feb 2018 06:00:38 AM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 28 Feb 2018 10:21:56 PM UTC, comment #15: 

I reviewed and committed the patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/a802e644937a).

I modified the search/replace code slightly to that below.

  srchstr[pos+1] = 't';  // "px" -> "pt"
  // Assume the second occurrence is at the same line
  pos = srchstr.find ("px", pos);
  srchstr[pos+1] = 't';  // "px" -> "pt"
  std::strcpy (str, srchstr.c_str ());


Instead of using the .replace() member function of strings I used direct access [] to replace the single character in question.  Also, rather than start the second search from position 0, I started it from the existing position to be a bit more efficient.

Marking bug as fixed.

@Michael: I'm not sure about the status of some of your comments in this report.  Do you want to file another bug report about the lack of documentation for pdfwriter and cropping?


Rik <rik5>
Group administrator
Wed 28 Feb 2018 09:14:57 PM UTC, comment #14: 

Now I did :-)

(file #43421)

Pantxo Diribarne <pantxo>
Group Member
Wed 28 Feb 2018 09:14:19 PM UTC, comment #13: 

I attached a patch.

Pantxo Diribarne <pantxo>
Group Member
Tue 27 Feb 2018 05:39:28 PM UTC, comment #12: 

I think it would be preferable to do it in gl2ps-print, although we should leave a FIXME note about how the change should be undone as soon as gl2ps addresses the issue.

Rik <rik5>
Group administrator
Tue 27 Feb 2018 09:54:34 AM UTC, comment #11: 

@Rik: Yes, the whole SVG document inherits the units used to the width and height in the "svg" element attributes.
We could use "regexprep", in a post processing step, to replace "width="XXXpx" height="XXXpx"" by "width="XXXpt" height="XXXpt"". Or we could do that directly in gl2ps-print, which would probably be faster since we know there should be only two occurrences of "px" at the beginning  of the files.

Pantxo Diribarne <pantxo>
Group Member
Tue 27 Feb 2018 02:10:06 AM UTC, comment #10: 

@Pantxo: Any possibility that we can implement a workaround in Octave until this is cleared up?  It looks like something in _print_parse_opts_ might work.

Rik <rik5>
Group administrator
Thu 22 Feb 2018 11:16:49 PM UTC, comment #9: 

@Pantxo: Just for information, when I need PDF plots for
publication I use:
  print (outfile, "-color", "-tight");
  cropcmd = ["pdfcrop " outfile " " outfile];
  system(cropcmd);
where outfile is the xxx.pdf.

This is the only way I could find to get output
which has a BB which just bounds the plot. Note that
-tight does not do it, and is surely unnecessary since
pdfcrop does what is needed.

Michael Godfrey <godfrey>
Group Member
Wed 21 Feb 2018 10:21:41 PM UTC, comment #8: 

@Pantxo: By the way, I already use the -tight option,
but it does not produce a minimum bounding box. So, it
is unclear what -tight actually does. The default as
stated in the manual is "loose" but is that actually
page (A4 or US)?

Is -tight equivalent to -dpdfwrite? If not do you know
what it does?

There is no intent to do "cropping" in the sense of
removing any drawn material. Just produce the BB that
exactly encloses the image. The only way that I have
found to do that is by means of pdfcrop.

I can check on all this when I get a bit of time...

Michael Godfrey <godfrey>
Group Member
Wed 21 Feb 2018 04:46:11 PM UTC, comment #7: 

I agree that this would be better to have fixed upstream, but the original e-mails documenting the problem are from 2015 and your e-mail to the mailing list is from 2016.  If it doesn't seem that a solution is imminent then we should patch Octave with a workaround.

And yes, this is a duplicate of earlier reports.  I didn't identify it as the same issue because the scaling factor before was 80%.  I've upgraded Inkscape recently and they are trying to follow the svg standard and move to a default of 96 dpi from 90 dpi.  The original scaling factor was 72/90 = 80%, but is now 72/96 = 75%.

Rik <rik5>
Group administrator
Wed 21 Feb 2018 04:13:03 PM UTC, comment #6: 

One of pdfcrop's options is the generate the minimum
bounding box. In any case, it uses ghostscript.

It appears that just some documentation would do the
job....

Michael Godfrey <godfrey>
Group Member
Wed 21 Feb 2018 03:41:19 PM UTC, comment #5: 

Actually I have already reported this issue on the bug tracker but got not feedback up to now:

https://gitlab.onelab.info/gl2ps/gl2ps/issues/20

Pantxo Diribarne <pantxo>
Group Member
Wed 21 Feb 2018 03:23:48 PM UTC, comment #4: 

@Michael: yes I agree that it should be clearly documented what -dpdfwrite ghostscript device does: it converts an eps (no surrounding page) into a pdf (no surrounding page either). So no, there is no cropping operation at play.
As for the default being croppped pdf, (i) this is a Matlab compatibility issue (not the most serious one) and (ii) other people could argue that they like to send their pdf top a printer...

Pantxo Diribarne <pantxo>
Group Member
Wed 21 Feb 2018 02:53:20 PM UTC, comment #3: 

@Pantxo: PDF may be viewed as a "paper format" but it
is widely used for insertion of figures in TeX/LaTex.
For many users it would be more convenient to have
cropped as the default, and page size as an option.

Also, there is just one reference to pdfwrite in the Manual.
It is under -dghostscript_device and does not mention that
it does cropping.

I will check how this cropping performs as compared to pdfcrop,
or does it use pdfcrop?

Michael Godfrey <godfrey>
Group Member
Wed 21 Feb 2018 12:33:37 PM UTC, comment #2: 

@Rik: I already reported to gl2ps mailing list this inconsistency between svg (screen pixel -> svg pixel = 80% of a point) and other formats (screen pixel -> -> point). I should open a ticket now they have a proper bug tracker.

@Dmitri: 150 dpi is the default resolution (see -r option for print) so it is ok and pdf is a paper format hence the presence of the surrounding page. If you want a cropped pdf use -dpdfwrite option.

Pantxo Diribarne <pantxo>
Group Member
Wed 21 Feb 2018 06:29:46 AM UTC, comment #1: 

Size of png and pdfs are also strange.
For png I got 600px x 600px which would make it right assuming 150 px/inch resolution. 
pdf still uses letter size paper (I assume this is ghostscript fault). "pdflatexstandalone" got it right.

Dmitri.

Dmitri A. Sergatskov <dasergatskov>
Wed 21 Feb 2018 06:00:38 AM UTC, original submission:  

The default PaperUnits are "inches".  When I set a value for PaperPosition, print to svg, and then check the resulting size in Inkscape, I find that the result is 75% of the size requested in Octave.

This is not like a word processor where What You See Is What You Get (WYSIWYG).

Code to reproduce:


close all
graphics_toolkit qt
plot (1:10, 'o-');
set (gcf, "PaperPosition", [0, 0, 4, 4]);
print tst_sz.svg



Rik <rik5>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #43421:  svg_units.patch added by pantxo (2KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-02-28 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2018-02-28 pantxo Attached File- Added svg_units.patch, #43421
    2018-02-21 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code