Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Radek Hušek
cups-pdf-postprocess
Commits
f38218f1
Commit
f38218f1
authored
Oct 02, 2017
by
Radek Hušek
Browse files
add print_compact
parent
e15ec051
Changes
2
Hide whitespace changes
Inline
Side-by-side
cups-pdf-postprocess.py
View file @
f38218f1
...
...
@@ -12,6 +12,7 @@ from PyQt5.QtCore import *
import
sys
import
subprocess
as
sp
import
ast
import
os
def
exec_pipeline
(
pipeline
,
inp
,
out
=
None
,
err_callback
=
None
):
def
make_proc
(
cmd
):
...
...
@@ -79,6 +80,32 @@ class CPP(QWidget):
o
.
setWordWrap
(
True
)
vbox
.
addWidget
(
o
)
hbox
=
QHBoxLayout
()
self
.
_compact
=
QCheckBox
(
'Compact'
,
self
)
self
.
_compact_copies
=
QSpinBox
(
self
)
self
.
_compact_copies
.
setMinimum
(
1
)
self
.
_compact_copies
.
setMaximum
(
1000
)
self
.
_compact_copies
.
setSingleStep
(
1
)
self
.
_compact_copies
.
setValue
(
1
)
self
.
_compact_copies
.
setEnabled
(
False
)
def
_compact_changed
(
enabled
):
self
.
_pdfbook
.
setEnabled
(
not
enabled
)
self
.
_compact_copies
.
setEnabled
(
enabled
)
if
enabled
:
self
.
_duplex
.
setCurrentIndex
(
1
)
self
.
_pdfbook
.
setChecked
(
False
)
_pdfbook_changed
(
False
)
else
:
self
.
_compact_copies
.
setValue
(
1
)
self
.
_duplex
.
setEnabled
(
not
enabled
)
self
.
_compact
.
clicked
[
bool
].
connect
(
_compact_changed
)
hbox
.
addWidget
(
self
.
_compact
)
hbox
.
addWidget
(
self
.
_compact_copies
)
vbox
.
addLayout
(
hbox
)
hbox
=
QHBoxLayout
()
hbox
.
addWidget
(
QLabel
(
"Duplex:"
))
self
.
_duplex
=
QComboBox
(
self
)
...
...
@@ -143,6 +170,10 @@ class CPP(QWidget):
if
self
.
_pdfbook
.
isChecked
():
pipeline
.
append
([
"pdfbook"
,
"/dev/stdin"
,
"-o"
,
"/dev/stdout"
])
if
self
.
_compact
.
isChecked
():
pipeline
.
append
([
"%s/%s"
%
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
sys
.
argv
[
0
])),
"print_compact.sh"
),
"%i"
%
self
.
_compact_copies
.
value
()
])
if
self
.
_printer
.
currentData
()
is
SAVE_AS_FILE
:
f
=
QFileDialog
.
getSaveFileName
(
self
,
'Save as ...'
)
if
not
f
[
0
]:
...
...
print_compact.sh
0 → 100755
View file @
f38218f1
#!/bin/bash
COPIES
=
"
${
1
:-
1
}
"
PDF
=
"
`
xxd
-p
`
"
PAGES
=
`
xxd
-p
-r
<<<
"
$PDF
"
| pdfinfo - |
sed
-nre
's/Pages:\s*(.*)/\1/p'
`
if
((
PAGES <
=
2
))
;
then
:
$((
COPIES
=
(
COPIES
+
1
)
/
2
))
fi
xxd
-p
-r
<<<
"
$PDF
"
|
case
$PAGES
in
1
)
pdfjam
--nup
2x1
--landscape
--doublepagestwistodd
\*
true
-o
/dev/stdout /dev/stdin 1,
'{}'
;;
2
)
pdfjam
--nup
2x1
--landscape
--doublepagestwistodd
\*
true
-o
/dev/stdout /dev/stdin 1,2
;;
*
)
pdfbook
-o
/dev/stdout /dev/stdin
;;
esac
| pdfjoin
-o
/dev/stdout /dev/stdin
`
python
-c
"print(','.join(['-']*
$COPIES
))"
`
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment