Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdf Cut: initial release #564

Merged
merged 3 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pdf-cut@ernemir/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### 1.0.0

* Initial release
14 changes: 14 additions & 0 deletions pdf-cut@ernemir/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PDF CUT

Cut a range of pages from a PDF file.

## DESCRIPTION

This action allows you to cut pages from a PDF document and generate a new one with that content. A simple graphical interface allows you to select the range of pages.

## DEPENDENCIES


The following programs must be installed and available:
* `zenity` for GUI;
* `gs` for PDF processing.
Binary file added pdf-cut@ernemir/files/pdf-cut@ernemir/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions pdf-cut@ernemir/files/pdf-cut@ernemir/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"description": "Cut a range of pages from a PDF file",
"uuid": "pdf-cut@ernemir",
"name": "PDF Cut",
"author": "ernemir",
"version": "1.0"
}
44 changes: 44 additions & 0 deletions pdf-cut@ernemir/files/pdf-cut@ernemir/pdf-cut.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
#
######################################################
# PDF Cut by ernemir, based on work by ScarletEmanu #
######################################################
#
#
TEXTDOMAINDIR=$HOME/.local/share/locale/
TEXTDOMAIN=pdf-cut@ernemir

_TITLE=$"PDF Cut"
TITLE="$(/usr/bin/gettext "$_TITLE")"
_TEXT=$"Enter page range"
TEXT="$(/usr/bin/gettext "$_TEXT")"
_FROM=$"From:"
FROM="$(/usr/bin/gettext "$_FROM")"
_TO=$"To:"
TO="$(/usr/bin/gettext "$_TO")"
_RANGE_ERROR=$"Invalid range"
RANGE_ERROR="$(/usr/bin/gettext "$_RANGE_ERROR")"
_NUMBER_ERROR=$"You must enter numbers"
NUMBER_ERROR="$(/usr/bin/gettext "$_NUMBER_ERROR")"

# Ask for page range
data=$(zenity --forms \
--title="$TITLE" \
--text="$TEXT" \
--add-entry="$FROM" \
--add-entry="$TO")
ans=$?
if [ $ans -eq 0 ]
then
IFS="|" read -r -a array <<< "$data"
if [[ ${array[0]} =~ ^[0-9]+$ ]] && [[ ${array[1]} =~ ^[0-9]+$ ]]; then
if [[ ! ${array[0]} > ${array[1]} ]]; then
output="${1%.*}_cut.pdf"
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage="${array[0]}" -dLastPage="${array[1]}" -sOutputFile="$output" "$1"
else
zenity --error --text "$RANGE_ERROR"
fi
else
zenity --error --text "$NUMBER_ERROR"
fi
fi
50 changes: 50 additions & 0 deletions pdf-cut@ernemir/files/pdf-cut@ernemir/po/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# PDF CUT
# This file is put in the public domain.
# ernemir, 2023
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: pdf-cut@ernemir 1.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-actions/"
"issues\n"
"POT-Creation-Date: 2024-11-13 12:14-0300\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.4.2\n"

#. metadata.json->description
#. Comment
msgid "Cut a range of pages from a PDF file"
msgstr "Recorta un rango de páginas de un archivo PDF"

#. metadata.json->name
#. Name
#. pdf-cut.sh:8
msgid "PDF Cut"
msgstr "Recorta PDF"

#. pdf-cut.sh:10
msgid "Enter page range"
msgstr "Ingrese el rango de páginas"

#. pdf-cut.sh:12
msgid "From:"
msgstr "Desde:"

#. pdf-cut.sh:14
msgid "To:"
msgstr "Hasta:"

#. pdf-cut.sh:16
msgid "Invalid range"
msgstr "Rango inválido"

#. pdf-cut.sh:18
msgid "You must enter numbers"
msgstr "Debe ingresar números"
49 changes: 49 additions & 0 deletions pdf-cut@ernemir/files/pdf-cut@ernemir/po/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# PDF CUT
# This file is put in the public domain.
# ernemir, 2023
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: pdf-cut@ernemir 1.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-actions/"
"issues\n"
"POT-Creation-Date: 2024-11-13 12:14-0300\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. metadata.json->description
#. Comment
msgid "Cut a range of pages from a PDF file"
msgstr ""

#. metadata.json->name
#. Name
#. pdf-cut.sh:8
msgid "PDF Cut"
msgstr ""

#. pdf-cut.sh:10
msgid "Enter page range"
msgstr ""

#. pdf-cut.sh:12
msgid "From:"
msgstr ""

#. pdf-cut.sh:14
msgid "To:"
msgstr ""

#. pdf-cut.sh:16
msgid "Invalid range"
msgstr ""

#. pdf-cut.sh:18
msgid "You must enter numbers"
msgstr ""
3 changes: 3 additions & 0 deletions pdf-cut@ernemir/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"author": "ernemir"
}
9 changes: 9 additions & 0 deletions pdf-cut@ernemir/[email protected]_action.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Nemo Action]
_Name=PDF Cut
_Comment=Cut a range of pages from a PDF file
Exec=<"pdf-cut@ernemir/pdf-cut.sh" %F>
Icon-Name=edit-cut-symbolic
Quote=double
Selection=s
Extensions=pdf;
Dependencies=zenity;gs;