[opensuse] postscript question.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Is there a way to add page numbers to the pages of a postscript file, so that they print in the paper? I have done this in the past with a2ps or similar, but this time the original is a ps file. I can, for instance, use "psnup -2 infile.ps outfile.ps" to rearrange it two pages per sheet, and I can print odd pages first, then even on the other side, and thus get 4 pages per sheet and save trees. But unless I number them with pencil I can easily get lost when ordering them. So the question is, how can I add the page numbers automatically? - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFGLBCmtTMYHG2NR9URAjmwAJsG/y5bUx8Xe54UtiexRA40FeVhlACeOiPq 5IaXhinbBQ94k0kMJTvZqj4= =dyaV -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Sunday 22 April 2007 18:49, Carlos E. R. wrote:
Hi,
...
So the question is, how can I add the page numbers automatically?
I have a related request: Can I annotate either the first page or all pages with the file name of the PostScript file being printed?
-- Cheers, Carlos Robinson
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Sunday 2007-04-22 at 20:14 -0700, Randall R Schulz wrote:
On Sunday 22 April 2007 18:49, Carlos E. R. wrote:
So the question is, how can I add the page numbers automatically?
I have a related request: Can I annotate either the first page or all pages with the file name of the PostScript file being printed?
Mmm... I have seen that done with ascii files... interesting. Let's generalize, then. How to add arbitrary strings? File name, page number, date of printing... - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFGLJ/XtTMYHG2NR9URAgyNAJ9brr6Y6bV7qWEm/bqA1k68Ozuk1wCfTwMS 6QZQMkX/xz3qdYbHKNnDVYE= =h6If -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Hello, On Apr 23 14:00 Carlos E. R. wrote (shortened):
The Sunday 2007-04-22 at 20:14 -0700, Randall R Schulz wrote:
I have a related request: Can I annotate either the first page or all pages with the file name of the PostScript file being printed?
Let's generalize, then. How to add arbitrary strings? File name, page number, date of printing...
For fixed strings (i.e. no page numbers) you can use the "page-label" option which will show a fixed string (without spaces) at the very top and bottom all of all pages, for example to get the idea try: echo -en "One\fTwo" | lp -d <queue> -o page-label="$(date +%F,%T)" Kind Regards Johannes Meixner -- SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany AG Nuernberg, HRB 16746, GF: Markus Rex -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Johannes, On Monday 23 April 2007 05:20, Johannes Meixner wrote:
Hello,
On Apr 23 14:00 Carlos E. R. wrote (shortened): ..
Let's generalize, then. How to add arbitrary strings? File name, page number, date of printing...
For fixed strings (i.e. no page numbers) you can use the "page-label" option which will show a fixed string (without spaces) at the very top and bottom all of all pages, for example to get the idea try:
echo -en "One\fTwo" | lp -d <queue> -o page-label="$(date +%F,%T)"
I'm a little confused by this example. Let's say I have a PostScript file name "report.ps". How would I print it with page labels equal to the file name? Secondly, is there a way to do this with PDF? (Apart, of course, from converting the PDF to PostScript before printing?) Lastly, is there a way to use this technique with the printing software used by document viewers such as KGhostView, kpdf or Adobe Reader? For the first two, at least, it's "kprinter." Reader uses its own custom printing GUI, apparently--it looks like no other printing dialog on my system. Thanks.
Kind Regards Johannes Meixner
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Monday 2007-04-23 at 14:20 +0200, Johannes Meixner wrote:
Let's generalize, then. How to add arbitrary strings? File name, page number, date of printing...
For fixed strings (i.e. no page numbers) you can use the "page-label" option which will show a fixed string (without spaces) at the very top and bottom all of all pages, for example to get the idea try:
echo -en "One\fTwo" | lp -d <queue> -o page-label="$(date +%F,%T)"
Curious! An undocumented feature! It is not in the man page of 'lp'. Are there more options? Ok. I tried this: psnup -2 -m1cm file.ps file-2-tremis.ps & gv file-2-tremis.ps & This converts to double page with a 1 cm margin (if I don't add the margin, the label will overwrite the print area later), and check with gv. Then: psselect -p9 file-2-tremis.ps pagina.ps && gv pagina.ps & This selects page 9 and output it to file "pagina.ps". Now, print: lp pagina.ps -o page-label="page 9" This printed a rough "page" in a box both at the top and bottom of the page - but the number "9" went missing. Then I tried: lp pagina.ps -o page-label="9" and this, finally, worked. I can manage to write a little script printing a range of pages, using psselect on each page. So, I have a working automated solution, although the output isn't nice. Curiously, the command "psnup" can print a nice border around the pages; I wonder why there isn't a program that can automate manipulation of the pages to add page numbers or any other text. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFGLRJVtTMYHG2NR9URAnwdAJ9HM9HHveB2pCOYRCc6cpm5OpHAdgCffj5u ceDXKVmO0hf0AMYazroZlbM= =RUE1 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Monday 23 April 2007 13:08, Carlos E. R. wrote:
The Monday 2007-04-23 at 14:20 +0200, Johannes Meixner wrote:
Let's generalize, then. How to add arbitrary strings? File name, page number, date of printing...
For fixed strings (i.e. no page numbers) you can use the "page-label" option which will show a fixed string (without spaces) at the very top and bottom all of all pages, for example to get the idea try:
echo -en "One\fTwo" | lp -d <queue> -o page-label="$(date +%F,%T)"
Curious! An undocumented feature! It is not in the man page of 'lp'. Are there more options?
Thanks for elaborating the example. For some reason when I first read Johannes' post, I didn't grok that "One\fTwo" were two pages of sample / simulated output that would be printed with the date/time-stamp page label.
... -- Cheers, Carlos E. R.
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Monday 2007-04-23 at 13:58 -0700, Randall R Schulz wrote:
Thanks for elaborating the example. For some reason when I first read Johannes' post, I didn't grok that "One\fTwo" were two pages of sample / simulated output that would be printed with the date/time-stamp page label.
I wrote an script. If you try it, don't send a long file, try it first with a single page, because the printed number is not very nice: a 7 millimeter box at the top and bottom edges of the paper, rough bold type. I don't like the code I wrote to detect if the parameters are digits, but its better than nothing. Very simple error detection. If there is a bad error when separating the pages or printing, it will not stop. #!/bin/bash # ~/bin/printpagewithnumber function syntax () { echo syntax error: I expected \"start_page_number end step\" exit } if test -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ; then FILE=$1 let "START = $2" let "END = $3" let "STEP = $4" if test "0$START" -gt 0 -a "0$END" -gt 0 -a "0$STEP" -gt 0 ; then echo Got numbers. else echo Parameters 2..4 were not numbers syntax fi if test -s $FILE ; then echo Got file let "PAGE = $START" echo "I'm going to print from page $START to page $END in $STEP pages steps" while ( test $PAGE -le $END ) ; do echo "Selecting page $PAGE" psselect -p$PAGE $FILE /tmp/pagina.ps echo "Sending page $PAGE to default printer" lp /tmp/pagina.ps -o page-label="$PAGE" let "PAGE = $PAGE + $STEP" done else echo File $FILE does not exist. syntax fi else echo "I will print pages from start to end by steps, adding a page number label" syntax fi echo Done - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFGLTtotTMYHG2NR9URAgreAJ9wB2fS2AAtBjvWrdy64OHDffHeGwCfSF55 bzszCqYAb3fTewu3kI6f3Bs= =v+ZD -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Hello, On Apr 23 22:08 Carlos E. R. wrote (shortened):
For fixed strings (i.e. no page numbers) you can use the "page-label" option which will show a fixed string (without spaces) at the very top and bottom all of all pages, for example to get the idea try: ... lp pagina.ps -o page-label="page 9" This printed a rough "page" in a box both at the top and bottom of the
The Monday 2007-04-23 at 14:20 +0200, Johannes Meixner wrote: ... page - but the number "9" went missing. Then I tried: lp pagina.ps -o page-label="9" and this, finally, worked.
Read carefully what I wrote ;-) By the way: The psutils are (sometimes) evil, see https://bugzilla.novell.com/show_bug.cgi?id=152448 Kind Regards Johannes Meixner -- SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany AG Nuernberg, HRB 16746, GF: Markus Rex -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Tuesday 2007-04-24 at 09:11 +0200, Johannes Meixner wrote:
Hello,
On Apr 23 22:08 Carlos E. R. wrote (shortened):
For fixed strings (i.e. no page numbers) you can use the "page-label" option which will show a fixed string (without spaces) at the very top and bottom all of all pages, for example to get the idea try: ... lp pagina.ps -o page-label="page 9" This printed a rough "page" in a box both at the top and bottom of the
The Monday 2007-04-23 at 14:20 +0200, Johannes Meixner wrote: ... page - but the number "9" went missing. Then I tried: lp pagina.ps -o page-label="9" and this, finally, worked.
Read carefully what I wrote ;-)
Sorry, I don't see what you mean :-? I simply used a fixed string that happens to be "page 9", and I don't understand why "page" prints, but "9" goes missing. Maybe you mean the "no spaces" thing? The spaces in the string confuses it? It seems a very crude thing... Anyway, I made a script to print a page range with page numbers.
By the way: The psutils are (sometimes) evil, see https://bugzilla.novell.com/show_bug.cgi?id=152448
Mmm... I don't think I bumped into that one. Anyway, my printer is an inkjet, not ps. You mention: | For number-up printing use the CUPS options and not the psutils, | see the "CUPS Software Users Manual": "Document Options". However, when browsing cups, the interface has changed, and I can't locate that section - not even using the search feature: On-Line Help Documents All Documents Getting Started Man Pages Programming References Specifications - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFGLdZbtTMYHG2NR9URAlqvAJ92ti3urFHFclOaoqyiGy/hbFGriACdE2Ru xZ954zHmJJMorOY1zp+g5sY= =Puyg -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 23-Apr-07 01:49:14, Carlos E. R. wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
Is there a way to add page numbers to the pages of a postscript . file, so that they print in the paper?
I have done this in the past with a2ps or similar, but this time the original is a ps file.
I can, for instance, use "psnup -2 infile.ps outfile.ps" to rearrange it two pages per sheet, and I can print odd pages first, then even on the other side, and thus get 4 pages per sheet and save trees. But unless I number them with pencil I can easily get lost when ordering them.
So the question is, how can I add the page numbers automatically?
In principle yes, but whether it is straightforward in practice
depends on the contents of the PostScript file (PS is such a
generalised language that there are many many ways in which the
same printed content can be represented in PsotScript).
The most favourable case is a PS file which is entirely plain
ASCII text with no hex-encoded content, and which contains DCS
("Document Structuring Convention") comments.
Such a comment always begins with "%%" at the start of a line,
such as
%%Pages: 4
%%PageOrder: Ascend
%%Orientation: Portrait
etc.
In that case, you will probably find DSC comments like
%%Page: 1 1
%%BeginPageSetup
<PostScript Code>
%%EndPageSetup
<More PostScript Code>
This is the best place for an automated page-numbering
system to start from. The following assumes that you
want the page number to be 1 inch (72 points) up from the
bottom of the page, and 1 inch in from the left, and that
the standard coordinate system is in operation (some
software may, for instance, invert the vertical so that
distance is measures from the top rather than the default
bottom of the page -- in which case the numbers will not
only be at the top left, but also upside down!).
%%Page: requires two arguments: the first is a page label
(which may be anything), and the second is a sequential
page number, starting from 1 at the first page of the
document. E.g.
%%Page: Title 1
%%Page: i 2
%%Page: ii 3
%%Page: 1 4
etc.
DSC Comments are not printed, but are there to assist
display software in displaying the document (e.g. jumping
to a particular page, and displaying page number and/or
label in a status box).
In that case, you can feed your PS file through an 'awk'
script in order to plant PS commands to print the (sequential)
page number. Example:
#! /bin/bash
awk '
{print $0}
/^%%Page:/{Pno = $3}
/^%%EndPageSetup/{
print( "gsave" )
print( "/Times-Roman findfont 12 scalefont setfont" )
print( "72 72 moveto" )
print( "(" Pno ") show" )
print( "grestore" )
}'
Store the above as a file, say "numps.awk", and make it
executable:
chmod 755 numps.awk
and then:
cat myfile.ps | ./numps.awk > mynewfile.ps
Check it with:
gv mynewfile.ps
and if it's OK then you can print it!
As I say, whether the above will work as intended depends
on how the PS file was created. If it has non-standard
features which interfere (e.g. inverted coordinates as
above) then the 'awk' script would need to be amended
accordingly. But at least this illustrates the principle.
Also, a PS file need not contain DSC comments at all, in
which case the above will not work, and a different
approach would have to be worked out.
Hoping this helps!
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding)
participants (4)
-
Carlos E. R.
-
efh@nessie.mcc.ac.uk
-
Johannes Meixner
-
Randall R Schulz