diff --git a/cups-x2go b/cups-x2go
index 853599f..801d886 100755
--- a/cups-x2go
+++ b/cups-x2go
@@ -17,14 +17,18 @@
 #  Free Software Foundation, Inc.,
 #  51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
+use Sys::Syslog qw( :DEFAULT setlogsock);
 use Sys::Hostname;
 use File::Basename;
 use File::Copy;
 use strict;
 
+setlogsock('unix');
+openlog($0,'','user');
+
 my $x2goserver = "local";
 my $printdsa = "/root/.x2go/ssh/.x2goprint/id_dsa";
-my $ps2pdf = "/usr/bin/gs -q -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=\"%s.pdf\" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f \"%s\"";
+my $ps2pdf = "/usr/bin/gs -q -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=\"%s.pdf\" -dAutoRotatePages=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite -f /usr/bin/margen-offset.ps \"%s\"";
 my $cfgfile="/etc/cups/cups-x2go.conf";
 my $userName;
 my @sessions;
@@ -69,7 +73,13 @@ sub getsessions
   my $sesslist;
   if ( $x2goserver eq "local" )
   {
-        $sesslist=`su $userName -c "x2golistsessions --all-servers"`;
+       open (SQLCONF, "</etc/x2go/x2gosql/sql");
+       my $cfgline=<SQLCONF>;
+       close (SQLCONF);
+       if(($cfgline=~m/local/)||($cfgline=~m/sqlite/))
+       {
+            $sesslist=`su $userName -c "x2golistsessions --all-servers"`;
+       }
   }
   else
   {
@@ -86,11 +96,17 @@ sub printfile
     if($phost eq $host)
     {
        my ($tm,$tm,$uid,$gid,$tm,$tm,$tm,$spooldir)=getpwnam("x2goprint");
-       my $spfile="$spooldir/$sess$bname";
+       ## I create the user x2goprint with home=/var/spool/cups/x2goprint
+       ## drwxrwxr-x 2 x2goprint x2goprint 4096 ago 12 20:20 /var/spool/cups/x2goprint
+       ## and put x2goprint to sudoers like the manual.
+       ## and "passwd -d x2goprint" as root
+       my $spfile="$spooldir/$bname";
        copy($pfile, $spfile);
        copy($tfile, "$spfile.title");
        chown $uid,$gid,$spfile;
-       system( "su x2goprint -c \"sudo x2goprint $userName $sess $sess$bname $sess$bname.title\"" );
+       chown $uid,$gid,"$spfile.title";
+       system( "su x2goprint -c \"sudo x2goprint $userName $sess $bname $bname.title\"" );
+       syslog('info', "su x2goprint -c sudo x2goprint $userName $sess $bname $bname.title");
     }
     else
     {
@@ -101,6 +117,7 @@ sub printfile
 
 my $uname=$ENV{USER};
 
+
 if (!$ARGV[0])
 {
     print "file cups-x2go:/ \"Virtual X2GO Printer\" \"CUPS-X2GO\" \"MFG:Generic;MDL:CUPS-X2GO Printer;DES:Generic CUPS-X2GO Printer;CLS:PRINTER;CMD:POSTSCRIPT;\"\n";
@@ -120,7 +137,7 @@ my $printOptions;
 my $printFile;
 
 ($jobID, $userName, $jobTitle, $copies, $printOptions, $printFile) =  @ARGV;
-
+syslog('info', "I received from cups-> $jobID $userName $jobTitle $copies $printOptions $sepa $printFile");
 
 my $tempFile;
 if (!$printFile)
@@ -129,7 +146,8 @@ if (!$printFile)
     my $uid = $userName;
     $jid =~ s/\W//g; #sanity check
     $uid =~ s/\W//g; #sanity check
-    $tempFile = "/tmp/$jid-$uid-cupsjob$$";
+    $tempFile = "$ENV{TMPDIR}/$jid-$uid-cupsjob$$";
+    syslog('info', "Come from STDIN -> it create tempFile = $tempFile\n");
     open (OUT, ">$tempFile") or die "ERROR: Cannot write $tempFile: $!\n";
     while(<STDIN>)
     {
@@ -157,8 +175,11 @@ for(my $i=0; $i<scalar(@sessions);$i++ )
      if(@sinfo[4] eq "R")
      {
          printfile( $printFile, $titleFile, @sinfo[3], @sinfo[1]);
+         syslog('info', "Call to printfile function with: $printFile $titleFile @sinfo[3] @sinfo[1]\n");
      }
 }
 
 unlink ($printFile);
 unlink ($titleFile);
+closelog;
+## to close syslog logging. 
