added copyright headerse
[swftools.git] / wx / pdf2swf.py
index 1c6c44b..7e3f4bd 100755 (executable)
@@ -1,5 +1,27 @@
 #!/usr/bin/env python
 # -*- coding: ISO-8859-15 -*-
+#
+# pdf2swf.py
+# graphical user interface for pdf2swf
+#
+# Part of the swftools package.
+# 
+# Copyright (c) 2008,2009 Matthias Kramm <kramm@quiss.org> 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
 
 import sys
 import wx
@@ -7,6 +29,7 @@ import os
 sys.path+=["../lib/python"]
 import gfx
 import images
+import stat
 
 basedir = os.getcwd()
 
@@ -67,6 +90,8 @@ def swfcombine(params):
     else:
         locations = [os.path.join(basedir, "swfcombine.exe"), 
                      "c:\\swftools\\swfcombine.exe"]
+        params = ['"'+p+'"' for p in params]
+
     for e in locations:
         if os.path.isfile(e):
             exe = e
@@ -74,11 +99,15 @@ def swfcombine(params):
 
     if hasattr(os,"spawnv"):
         print "spawnv",exe,params
-        ret = os.spawnv(os.P_WAIT, exe, [exe]+params)
+        ret = -1
+        try:
+            ret = os.spawnv(os.P_WAIT, exe, ["swfcombine"]+params)
+        except:
+            ret = -1
         if not ret:
             return
 
-    cmd = exe + " " + (" ".join(params))
+    cmd = '"' + exe + '"' + " " + (" ".join(params))
     print "system",cmd
     ret = os.system(cmd)
     if ret&0xff00:
@@ -674,13 +703,19 @@ class State:
             page.render(swf)
             swf.endpage()
         swf.save(filename)
+        if not os.path.isfile(filename):
+            error("Couldn't create file "+filename)
 
         if gfx_options.get("rfxview",None):
             rfxview = os.path.join(basedir, "rfxview.swf")
             if not os.path.isfile(rfxview):
                 error("File rfxview.swf not found in working directory")
             else:
+                size1 = os.stat(filename)[stat.ST_SIZE]
                 swfcombine([rfxview,"viewport="+filename,"-o",filename])
+                size2 = os.stat(filename)[stat.ST_SIZE]
+                if size1 == size2:
+                    error("Couldn't add viewer to file "+filename)
         
         if html:
             version = int(gfx_options.get("flashversion", "8"))
@@ -1029,24 +1064,6 @@ class Pdf2swfFrame(wx.Frame):
             hsplit.SplitVertically(self.pagelist, self.onepage, sashPosition=ICON_SIZE*3/2)
             hsplit.SetMinimumPaneSize(10)
 
-#class TestWindow(wx.SplitterWindow):
-#    def __init__(self,parent):
-#        wx.SplitterWindow.__init__(self, parent, -1)
-#        panel = wx.Panel(self, -1)
-#        self.txt = wx.StaticText(panel, -1, "bla bla bla", (100,10), (160,-1), wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL)
-#        self.SetMinSize((320,200))
-#        self.txt.SetForegroundColour("blue")
-#        self.txt.SetBackgroundColour("green")
-#        self.Fit()
-#        self.Initialize(panel)
-#
-#class TestFrame(wx.Frame):
-#    def __init__(self,parent):
-#        wx.Frame.__init__(self, None, -1)
-#        panel = wx.Panel(self, -1)
-#        window = TestWindow(panel)
-#        window.Show()
-
 class MyApp(wx.App):
     def __init__(self):
         wx.App.__init__(self, redirect=False, filename=None, useBestVisual=False)