--- psprint/inc/psprint/printerjob.hxx	2005-09-08 18:35:45.000000000 +0200
+++ psprint/inc/psprint/printerjob.hxx	2006-05-16 20:23:54.000000000 +0200
@@ -99,7 +99,7 @@ private:            // private methods
 
     bool			writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup );
     bool            writeSetup( osl::File* pFile, const JobData& );
-    bool            writePageSetup( osl::File* pFile, const JobData& );
+    bool            writePageSetup( osl::File* pFile, const JobData&, bool bWriteFeatures = true );
     void			writeJobPatch( osl::File* File, const JobData& );
     bool            writeProlog (osl::File* pFile, const JobData& );
 
--- psprint/source/printergfx/printerjob.cxx	2006-05-04 10:41:55.000000000 +0200
+++ psprint/source/printergfx/printerjob.cxx	2006-05-16 20:23:10.000000000 +0200
@@ -1047,14 +1047,6 @@ PrinterJob::StartPage (const JobData& rJ
     if( ! (pPageHeader && pPageBody) )
         return sal_False;
 
-    /* #i7262# write setup only before first page
-     *  don't do this in StartJob since the jobsetup there may be
-     *  different.
-     */ 
-    bool bSuccess =  true;
-    if( 1 == maPageList.size() )
-        m_aDocumentJobData = rJobSetup;
-
     // write page header according to Document Structuring Conventions (DSC)
     WritePS (pPageHeader, "%%Page: ");
     WritePS (pPageHeader, aPageNo); 
@@ -1077,13 +1069,25 @@ PrinterJob::StartPage (const JobData& rJ
 
     WritePS (pPageHeader, pBBox);
 
-    if (bSuccess)
-        bSuccess = writePageSetup ( pPageHeader, rJobSetup );
-    if(bSuccess)
-        m_aLastJobData = rJobSetup;
+    /* #i7262# #i65491# write setup only before first page
+     *  (to %%Begin(End)Setup, instead of %%Begin(End)PageSetup)
+     *  don't do this in StartJob since the jobsetup there may be
+     *  different.
+     */ 
+    bool bWriteFeatures = true;
+    if( 1 == maPageList.size() )
+    {
+        m_aDocumentJobData = rJobSetup;
+        bWriteFeatures = false;
+    }
 
+    if ( writePageSetup( pPageHeader, rJobSetup, bWriteFeatures ) )
+    {
+        m_aLastJobData = rJobSetup;
+        return true;
+    }
         
-    return bSuccess;
+    return false;
 }
 
 sal_Bool
@@ -1174,12 +1178,9 @@ bool PrinterJob::writeFeatureList( osl::
                 if( pKey->getSetupType()    == PPDKey::DocumentSetup )
                     bEmit = true;
             }
-            else
-            {
-                if( pKey->getSetupType()    == PPDKey::PageSetup        ||
-                    pKey->getSetupType()    == PPDKey::AnySetup )
-                    bEmit = true;
-            }
+            if( pKey->getSetupType()    == PPDKey::PageSetup        ||
+                pKey->getSetupType()    == PPDKey::AnySetup )
+                bEmit = true;
             if( bEmit )
             {
                 const PPDValue* pValue = rJob.m_aContext.getValue( pKey );
@@ -1213,13 +1214,13 @@ bool PrinterJob::writeFeatureList( osl::
     return bSuccess;
 }
 
-bool PrinterJob::writePageSetup( osl::File* pFile, const JobData& rJob )
+bool PrinterJob::writePageSetup( osl::File* pFile, const JobData& rJob, bool bWriteFeatures )
 {
     bool bSuccess = true;
 
     WritePS (pFile, "%%BeginPageSetup\n%\n");
-
-    bSuccess = writeFeatureList( pFile, rJob, false );
+    if ( bWriteFeatures )
+        bSuccess = writeFeatureList( pFile, rJob, false );
     WritePS (pFile, "%%EndPageSetup\n");
 
     sal_Char  pTranslate [128];
