commit 239665f3f5c0c8a1126dc57527977b7832425cf1 Author: Benjamin Renard Date: Tue Apr 29 19:41:51 2014 +0200 Initial release diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000..9b604be --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1,5 @@ +*.debhelper.log +*.substvars +compress-pdf +files +dirs diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..852b5c5 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +compress-pdf (1.4-1) unstable; urgency=low + + * Initial Debian release + + -- Benjamin Renard Tue, 29 Apr 2014 19:00:47 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/compress-pdf.install b/debian/compress-pdf.install new file mode 100644 index 0000000..b4d46f1 --- /dev/null +++ b/debian/compress-pdf.install @@ -0,0 +1,3 @@ +src/usr/bin/compress-pdf usr/bin/ +src/usr/share/applications/compress-pdf.desktop usr/share/applications/ +src/usr/share/icons/* usr/share/icons/ diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..f073554 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: compress-pdf +Section: gnome +Priority: optional +Build-Depends: debhelper +Maintainer: Benjamin Renard +Homepage: http://git.zionetrix.net/compress-pdf + +Package: compress-pdf +Section: x11 +Architecture: all +Depends: zenity, ghostscript +Maintainer: Benjamin Renard +Description: graphical tool to compress PDF file using GhostScript + Compress PDF is a graphical tool to compress PDF file using GhostScript and zenity for UI. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..d08a5a5 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,24 @@ +This package was debianized by Benjamin Renard on +Tue, 29 Apr 2014 19:06:13 +0200. + +This package was build from Compress PDF sources version 1.4 adapted by packager. + +Original source is available here : + +https://launchpad.net/compress-pdf/ + +Copyright: + + compress-pdf is copyright (C) 2010 Ricardo Ferreira + + This software is issued from GNU GENERAL PUBLIC LICENSE Version 3 + +License: + + You can use it under GNU GENERAL PUBLIC LICENSE Version 3 policy + + For more information on GNU GENERAL PUBLIC LICENSE Version 3 policy, + please refer to COPYING. + +The Debian packaging is (C) 2013, Benjamin Renard and +is licensed under the GNU GENERAL PUBLIC LICENSE Version too. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..65028fd --- /dev/null +++ b/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ diff --git a/src/usr/bin/compress-pdf b/src/usr/bin/compress-pdf new file mode 100755 index 0000000..208665b --- /dev/null +++ b/src/usr/bin/compress-pdf @@ -0,0 +1,212 @@ +#! /bin/bash + +# AUTHOR: (c) Ricardo Ferreira +# NAME: Compress PDF 1.4 +# DESCRIPTION: A nice Nautilus script with a GUI to compress and optimize PDF files +# REQUIRES: ghostscript, poppler-utils, zenity +# LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html) +# WEBSITE: https://launchpad.net/compress-pdf + +# Messages + # English (en-US) + error_nofiles="No file selected." + error_noquality="No optimization level selected." + error_ghostscript="PDF Compress requires the ghostscript package, which is not installed. Please install it and try again." + error_nopdf="The selected file is not a valid PDF archive." + label_filename="Save PDF as..." + label_level="Please choose an optimization level below." + optimization_level="Optimization Level" + level_default="Default" + level_screen="Screen-view only" + level_low="Low Quality" + level_high="High Quality" + level_color="High Quality (Color Preserving)" + job_done="has been successfully compressed" + +case $LANG in + + pt* ) + # Portuguese (pt-PT) + error_nofiles="Nenhum ficheiro seleccionado." + error_noquality="Nenhum nível de optimização escolhido." + error_ghostscript="O PDF Compress necessita do pacote ghostscript, que não está instalado. Por favor instale-o e tente novamente." + error_nopdf="O ficheiro seleccionado não é um ficheiro PDF válido." + label_filename="Guardar PDF como..." + label_level="Por favor escolha um nível de optimização abaixo." + optimization_level="Nível de Optimização" + level_default="Normal" + level_screen="Visualização no Ecrã" + level_low="Baixa Qualidade" + level_high="Alta Qualidade" + level_color="Alta Qualidade (Preservação de Cores)" + job_done="foi comprimido com sucesso";; + + + es* ) + # Spanish (es-AR) by Eduardo Battaglia + error_nofiles="Ningún archivo seleccionado." + error_noquality="Ningún nivel de optimización escogido." + error_ghostscript="Compress PDF necesita el paquete ghostscript, que no está instalado. Por favor instálelo e intente nuevamente." + label_filename="Guardar PDF como..." + label_level="Por favor escoja un nivel de optimización debajo." + optimization_level="Nivel de Optimización" + level_default="Normal" + level_screen="Sólo visualización" + level_low="Baja calidad" + level_high="Alta calidad" + level_color="Alta calidad (Preservación de Colores)";; + + + cs*) + # Czech (cz-CZ) by Martin Pavlík + error_nofiles="Nebyl vybrán žádný soubor." + error_noquality="Nebyla zvolena úroveň optimalizace." + error_ghostscript="PDF Compress vyžaduje balíček ghostscript, který není nainstalován. Nainstalujte jej prosím a opakujte akci." + label_filename="Uložit PDF jako..." + label_level="Prosím vyberte úroveň optimalizace z níže uvedených." + optimization_level="Úroveň optimalizace" + level_default="Výchozí" + level_screen="Pouze pro čtení na obrazovce" + level_low="Nízká kvalita" + level_high="Vysoká kvalita" + level_color="Vysoká kvalita (se zachováním barev)";; + + + fr*) + # French (fr-FR) by Astromb + error_nofiles="Aucun fichier sélectionné" + error_noquality="Aucun niveau d'optimisation sélectionné" + error_ghostscript="PDF Compress a besoin du paquet ghostscript, mais il n'est pas installé. Merci de l'installer et d'essayer à nouveau." + error_nopdf="Le fichier que vous avez sélectionné n'est pas un PDF valide." + label_filename="Sauvegarder le PDF sous..." + label_level="Merci de choisir, ci-dessous, un niveau d'optimisation." + optimization_level="Niveau d'optimisation" + level_default="Défaut" + level_screen="Affichage à l'écran" + level_low="Basse qualité" + level_high="Haute qualité" + level_color="Haute qualité (Couleurs préservées)" + job_done="a bien été compressé";; + + zh_CN*) + # Simplified Chinese (zh_CN) by TualatriX Chou + error_nofiles="没有选择文件。" + error_noquality="没有优化优化等级。" + error_ghostscript="PDF压缩需要ghostscript软件包,但是它没有安装。请先安装然后再重试。" + error_nopdf="选择的文件不是一个有效的PDF文件" + label_filename="另存为PDF..." + label_level="请在下面选择优化等级" + optimization_level="优化等级" + level_default="默认" + level_screen="仅在屏幕上浏览" + level_low="低品质" + level_high="高品质" + level_color="高品质(护色) ";; + + ar*) + # Arabic (ar) by Mohammed hasan Taha + error_nofiles="لم يتم اختيار ملف" + error_noquality="لم يتم اختيار درجة الضغط" + error_ghostscript="هذا السكربت يحتاج حزمة ghostscript package لذا يرجى تنصيبها ثم اعادة المحاولة" + error_nopdf="الملف الذي تم اختياره ليس ملف pdf صالح" + label_filename="حفظ الملف باسم" + label_level="الرجاء اختيار درجة الضغط" + optimization_level="درجة الضغط" + level_default="افتراضي" + level_screen="عرض للشاشة فقط(الدرجة الأكثر انخفاضا)" + level_low="جودة منخفضة" + level_high="جودة مرتفعة" + level_color="جودة عالية جدا";; + + ml_IN*) + # Malayalam (ml_IN) by Hrishikesh K B + error_nofiles="ഒരു ഫയലും തിരഞ്ഞെടുത്തിട്ടില്ല." + error_noquality="യാതൊരു ഒപ്റ്റിമൈസേഷന്‍ ലെവലും തിരഞ്ഞെടുത്തിട്ടില്ല." + error_ghostscript="പി ഡി എഫ് കംപ്രസ്സറിന് ഗോസ്റ്റ് സ്ക്രിപ്റ്റ് പാക്കേജ് ആവശ്യമാണ്. ആ പാക്കേജ് ഇന്‍സ്റ്റാള്‍ ചെയ്‌‌ത ശേഷം ദയവായി വീണ്ടും ശ്രമിക്കുക." + error_nopdf="തിരഞ്ഞെടുത്ത ഫയല്‍ സാധുവായ ഒരു പിഡിഎഫ് ആര്‍ച്ചീവ് അല്ല." + label_filename="പിഡിഎഫ് ഇങ്ങിനെ സംരക്ഷിക്കുക..." + label_level="ദയവായി താഴെ നിന്നും ഒരു ഒപ്റ്റിമൈസേഷന്‍ ലെവല്‍ തിരഞ്ഞെടുക്കുക." + optimization_level="ഒപ്റ്റിമൈസേഷന്‍ ലെവല്‍ " + level_default="ഡീഫാള്‍ട്ട്" + level_screen="സ്ക്രീനില്‍ കാണാന്‍ മാത്രം " + level_low="കുറഞ്ഞ നിലവാരം" + level_high="കൂടിയ നിലവാരം " + level_color="കൂടിയ നിലവാരം (നിറം സംരക്ഷിച്ചിട്ടുള്ളത്)" + +esac + +VERSION="1.1" +ZENITY=$(which zenity) + +pdf_file=$(basename "$1") + +# Check if Ghostscript is installed +GS="/usr/bin/ghostscript" +if [ ! -x $GS ]; then + $ZENITY --error --title="Compress PDF "$VERSION"" --text="$error_ghostscript" + exit 0; +fi + +# Check if the user has selected any files +if [ ! -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then + pdf_file="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" +elif [ -z "$pdf_file" ]; then + pdf_file=$($ZENITY --file-selection --file-filter="*.pdf" --title="$label_filename") + [ $? -ne 0 ] && exit 0 +fi + +# Check if the selected file is a PDF... +mimetype=$(file -b -i "$pdf_file") +if [ -z "`echo $mimetype | grep -i 'pdf' `" ]; then + $ZENITY --error --title="Compress PDF "$VERSION"" --text="$error_nopdf" + exit 0; +fi + +# Ask the user to select a compressing format +selected_level=$($ZENITY --list --title="Compress PDF "$VERSION"" --text "$label_level" --radiolist --column "" --column "$optimization_level" TRUE "$level_default" FALSE "$level_screen" FALSE "$level_low" FALSE "$level_high" FALSE "$level_color") +if [ -z "$selected_level" ]; then + $ZENITY --error --title="Compress PDF "$VERSION"" --text="$error_noquality" + exit 0; +fi + +# Select the optimization level to use +case $selected_level in + "$level_default") + COMP_COMMAND="/default" + ;; + "$level_screen") + COMP_COMMAND="/screen" + ;; + "$level_low") + COMP_COMMAND="/ebook" + ;; + "$level_high") + COMP_COMMAND="/printer" + ;; + "$level_color") + COMP_COMMAND="/prepress" + ;; +esac + +# Choose output file name +suggested_filename=compressed-"$pdf_file" +output_filename=$($ZENITY --file-selection --save --confirm-overwrite --filename="$suggested_filename" --title="$label_filename") + +if [ "$?" = 1 ] ; then + exit 0; +fi +temp_filename="$( dirname "$output_filename")/.$( basename "$output_filename").temp" + +# Execute ghostscript while showing a progress bar +(echo "0" ; + gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=$COMP_COMMAND -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$temp_filename" "$pdf_file"; + rm -f "$temp_filename_pdfmarks"; + echo "100") | (if `$ZENITY --progress --pulsate --auto-close --title="Compress PDF "$VERSION""`; + then + mv -f "$temp_filename" "$output_filename" & + notify-send "Compress PDF" "$pdf_file $job_done" + else + killall gs + rm -f "$temp_filename" + exit + fi) diff --git a/src/usr/share/applications/compress-pdf.desktop b/src/usr/share/applications/compress-pdf.desktop new file mode 100644 index 0000000..1538d8b --- /dev/null +++ b/src/usr/share/applications/compress-pdf.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Compress PDF +Comment=Compress PDF file +Exec=compress-pdf +Terminal=false +Type=Application +Icon=compress-pdf +Categories=GNOME;GTK;Office;Viewer;Graphics;VectorGraphics; +MimeType=application/pdf;application/x-bzpdf;application/x-gzpdf;application/x-xzpdf; diff --git a/src/usr/share/icons/hicolor/16x16/apps/compress-pdf.png b/src/usr/share/icons/hicolor/16x16/apps/compress-pdf.png new file mode 100644 index 0000000..2ba093f Binary files /dev/null and b/src/usr/share/icons/hicolor/16x16/apps/compress-pdf.png differ diff --git a/src/usr/share/icons/hicolor/22x22/apps/compress-pdf.png b/src/usr/share/icons/hicolor/22x22/apps/compress-pdf.png new file mode 100644 index 0000000..bf91abb Binary files /dev/null and b/src/usr/share/icons/hicolor/22x22/apps/compress-pdf.png differ diff --git a/src/usr/share/icons/hicolor/24x24/apps/compress-pdf.png b/src/usr/share/icons/hicolor/24x24/apps/compress-pdf.png new file mode 100644 index 0000000..bfb9edf Binary files /dev/null and b/src/usr/share/icons/hicolor/24x24/apps/compress-pdf.png differ diff --git a/src/usr/share/icons/hicolor/256x256/apps/compress-pdf.png b/src/usr/share/icons/hicolor/256x256/apps/compress-pdf.png new file mode 100644 index 0000000..1af53c8 Binary files /dev/null and b/src/usr/share/icons/hicolor/256x256/apps/compress-pdf.png differ diff --git a/src/usr/share/icons/hicolor/32x32/apps/compress-pdf.png b/src/usr/share/icons/hicolor/32x32/apps/compress-pdf.png new file mode 100644 index 0000000..0234658 Binary files /dev/null and b/src/usr/share/icons/hicolor/32x32/apps/compress-pdf.png differ diff --git a/src/usr/share/icons/hicolor/48x48/apps/compress-pdf.png b/src/usr/share/icons/hicolor/48x48/apps/compress-pdf.png new file mode 100644 index 0000000..8c3d981 Binary files /dev/null and b/src/usr/share/icons/hicolor/48x48/apps/compress-pdf.png differ