Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cups-pdf-postprocess
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Radek Hušek
cups-pdf-postprocess
Commits
f38218f1
Commit
f38218f1
authored
7 years ago
by
Radek Hušek
Browse files
Options
Downloads
Patches
Plain Diff
add print_compact
parent
e15ec051
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cups-pdf-postprocess.py
+31
-0
31 additions, 0 deletions
cups-pdf-postprocess.py
print_compact.sh
+17
-0
17 additions, 0 deletions
print_compact.sh
with
48 additions
and
0 deletions
cups-pdf-postprocess.py
+
31
−
0
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
]:
...
...
This diff is collapsed.
Click to expand it.
print_compact.sh
0 → 100755
+
17
−
0
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
))"
`
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment