--- D:/install/programming/cairo-1.5.4.tar/cairo-1.5.4_/cairo-1.5.4/src/cairo-ps-surface.c	Sat Dec 01 01:14:47 2007
+++ D:/install/programming/cairo-1.5.4.tar/cairo-1.5.4/src/cairo-ps-surface.c	Sat Dec 22 00:08:56 2007
@@ -48,10 +48,13 @@
 #include "cairo-output-stream-private.h"
 
 #include <ctype.h>
 #include <time.h>
 #include <zlib.h>
+#ifdef WIN32
+#include <windows.h>
+#endif
 
 #define DEBUG_PS 0
 
 typedef enum _cairo_image_transparency {
     CAIRO_IMAGE_IS_OPAQUE,
@@ -897,11 +900,36 @@
     _cairo_surface_init (&surface->base, &cairo_ps_surface_backend,
 			 CAIRO_CONTENT_COLOR_ALPHA);
 
     surface->final_stream = stream;
 
+#ifdef WIN32
+    if(1) {
+		DWORD temp_path_length;
+	    char temp_path_name[MAX_PATH + 1];
+	    char temp_file_name[MAX_PATH + 1];
+
+	    /* get the temp path */
+	    temp_path_length = GetTempPathA(MAX_PATH, temp_path_name);
+	    if ((temp_path_length <= MAX_PATH) && (temp_path_length > 0)) {
+	    
+		    /*create a temporary file name in temp path */
+	        if(GetTempFileNameA(temp_path_name, "PS", 0, temp_file_name) != 0) {
+	            surface->tmpfile = fopen(temp_file_name, "wb");
+	        }
+			else {
+				surface->tmpfile = NULL;
+			}
+	    }
+		else {
+			surface->tmpfile = NULL;
+	    }
+		
+	}
+#else
     surface->tmpfile = tmpfile ();
+#endif
     if (surface->tmpfile == NULL)
 	goto CLEANUP_SURFACE;
 
     surface->stream = _cairo_output_stream_create_for_file (surface->tmpfile);
     status = _cairo_output_stream_get_status (surface->stream);
