Bug 139495 - wrong BoundingBox values in EPS output
Summary: wrong BoundingBox values in EPS output
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.3.1
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-02 11:43 UTC by Falk-Florian Henrich
Modified: 2007-01-04 02:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Falk-Florian Henrich 2007-01-02 11:43:28 UTC
Version:           1.3.1 (using KDE KDE 3.5.5)
Installed from:    Fedora RPMs
OS:                Linux

When using the export to EPS feature, the resulting encapsulates PostScript file has a wrong bounding box value. In most cases the bounding box is too large, leaving a thick white border around the chart.
Comment 1 Andrew Walker 2007-01-04 02:32:24 UTC
SVN commit 619695 by arwalker:

BUG:139495 Set the BoundingBox values correctly for an EPS file

 M  +17 -4     kstviewwindow.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstviewwindow.cpp #619694:619695
@@ -234,7 +234,9 @@
   if (!view()->children().isEmpty()) {
     QString filenameNew;
     QString filenameNewEps;
-
+    int right;
+    int bottom;
+    
     {
       QPrinter printer(QPrinter::HighResolution);
       QString dotFormat = QString(".eps");
@@ -251,13 +253,16 @@
       if ( size.height() / 8 > resolution ) {
         resolution = size.height() / 8;
       }
-      
+      right = ( 72 * size.height() ) / resolution;
+      bottom = ( 72 * size.width() ) / resolution;
+            
+      printer.setMargins(0, 0, 0, 0);
       printer.setResolution(resolution);
       printer.setPageSize(QPrinter::Letter);
       printer.setOrientation(QPrinter::Landscape);
       printer.setOutputToFile(true);
       printer.setOutputFileName(filenameNew);
-      
+
       KstPainter paint(KstPainter::P_PRINT);
       paint.begin(&printer);
       QPaintDeviceMetrics metrics(&printer);
@@ -279,7 +284,7 @@
       if (fileEPS.open(IO_WriteOnly | IO_Truncate)) {
         QTextStream streamPS(&filePS);
         QTextStream streamEPS(&fileEPS);
-
+                
         line = streamPS.readLine();
         if (!line.isNull()) {
           if (line.left(11) == "%!PS-Adobe-") {
@@ -287,6 +292,14 @@
             // we have a ps file, so do the conversion...
             //
             streamEPS << "%!PS-Adobe-2.0 EPSF-2.0\n";
+            
+            line = streamPS.readLine();
+            if (!line.isNull() && line.left(14) == "%%BoundingBox:") {
+              streamEPS << "%%BoundingBox: 0 0 " << right << " " << bottom << "\n";            
+            } else {
+              streamEPS << line << "\n";
+            }
+            
             while (!streamPS.atEnd()) {
               line = streamPS.readLine();
               streamEPS << line << "\n";