zsh compare size pdf and delete bigger?

I have used an script to reduce the size of multiples pdf. This script creates files with the same name but with different extension. The extension of the compressed files is xpdf. Sometimes the "compressed" xpdf are bigger than the "uncompressed"pdf. I want to create a zsh script to compare each compressed with its respectively uncompressed and delete the one that has a bigger size. Can you give some advice?

confirm you can get the size by command : stat -c %s yourfile , otherwise, replace by :

ls -l $pdf | awk '{ print $5}'
for pdf in *.pdf
do
   Spdf=$( stat -c %s $pdf)
   xpdf=${pdf/.pdf}.xpdf
   if [ -f $xpdf ] ; then
      Sxpdf=$( stat -c %s $xpdf)
   else
      echo "$xpdf is not exist"
      exit
   fi
   
   # delete the bigger one 
   if [ "$Spdf" -gt "$Sxpdf" ]; then
      rm $xpdf
   else
      mv $xpdf $pdf
   fi
done