You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation indicates that saveImage() should be able to write to pdf files. But, at least in my case on Windows, if you pass a filename like "test.pdf", the file is not written. The issue is that the variable "selFormat" in JKQTBasePlotter::saveImage() is only set if it is parsed out of the filesave dialog, which is skipped if the filename is already set:
if (!fn.isEmpty()) {
int filtID=filt.indexOf(selFormat);
After this, filtID is -1, and things are not right from that point on. At this point, an invalid reference gets passed to JKQTBasePlotter::savePixelImage(), which has similar logic, and also finds filtID = -1. Then, the only reason the other formats work at all is that QImage.save() knows how to save all the image formats based on the extension.
I suspect SVG file saving is similarly broken for this use case.
My quick workaround was to use saveAsPDF() directly.
In the end, JKQTBasePlotter::saveImage() (and maybe JKQTBasePlotter::savePixelImage()) should probably be reviewed to insure that they work properly for all file types they support, when the filename is set prior to calling. I don't have time to do this now, but maybe later.
The text was updated successfully, but these errors were encountered:
…::saveImage() when passing a filename ending in ".pdf" (thanks to https://github.com/fpalazzolo for reporting)
IMPROVED/REWORKED: The functions JKQTBasePlotter::saveImage(), JKQTBasePlotter::saveAsPixelImage(), JKQTBasePlotter::saveAsPDF(), JKQTBasePlotter::saveSVG(), ... gained a bool return value to indicate whether sacing was successful.
IMPROVED/REWORKED: More <code>save...()</code> functions will appear in the API of JKQTPlotter, so you don't have to go via JKQTPlotter::getPlotter(). These are merely forwarding the call to the internel JKQTBasePlotter instance.
The documentation indicates that saveImage() should be able to write to pdf files. But, at least in my case on Windows, if you pass a filename like "test.pdf", the file is not written. The issue is that the variable "selFormat" in JKQTBasePlotter::saveImage() is only set if it is parsed out of the filesave dialog, which is skipped if the filename is already set:
and then later:
After this, filtID is -1, and things are not right from that point on. At this point, an invalid reference gets passed to JKQTBasePlotter::savePixelImage(), which has similar logic, and also finds filtID = -1. Then, the only reason the other formats work at all is that QImage.save() knows how to save all the image formats based on the extension.
I suspect SVG file saving is similarly broken for this use case.
My quick workaround was to use saveAsPDF() directly.
In the end, JKQTBasePlotter::saveImage() (and maybe JKQTBasePlotter::savePixelImage()) should probably be reviewed to insure that they work properly for all file types they support, when the filename is set prior to calling. I don't have time to do this now, but maybe later.
The text was updated successfully, but these errors were encountered: