Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Ghostscript to merge documents and add watermark

1,721 views
Skip to first unread message

Kevin Brault

unread,
Jul 26, 2003, 1:14:33 AM7/26/03
to
Hi everyone,

I am rather new to Ghostscript and I have to admit I am struggling a bit.

I have several PDF files that I would like to merge into one PDF and add a
watermark. I would like to do this with a batch command.

Can anyone give me the syntax to do this in Ghostscript? Can it be done in
Ghostscript?


Thank you in advance for your help!


Kevin


Roger Willcocks

unread,
Jul 26, 2003, 6:26:25 AM7/26/03
to

"Kevin Brault" <kevinj...@hotmail.com> wrote in message
news:Y6oUa.26779$Ne.17728@fed1read03...

> Hi everyone,
>
> I am rather new to Ghostscript and I have to admit I am struggling a bit.
>
> I have several PDF files that I would like to merge into one PDF and add a
> watermark. I would like to do this with a batch command.
>
> Can anyone give me the syntax to do this in Ghostscript? Can it be done in
> Ghostscript?
>

What has this got to do with comp.lang.postscript ?

>
> Thank you in advance for your help!
>
>
> Kevin
>
>

--
Roger


Kevin Brault

unread,
Jul 26, 2003, 9:42:27 AM7/26/03
to
Can this be done in the PS language and then PDF'd?


"Roger Willcocks" <rk...@rops.org> wrote in message
news:bftkvl$pti$1$8300...@news.demon.co.uk...

Roger Willcocks

unread,
Jul 26, 2003, 1:25:59 PM7/26/03
to
"Kevin Brault" <kevinj...@hotmail.com> wrote in message
news:6zvUa.27006$Ne.5155@fed1read03...

>
> news:bftkvl$pti$1$8300...@news.demon.co.uk...
> >
> > "Kevin Brault" <kevinj...@hotmail.com> wrote in message
> > news:Y6oUa.26779$Ne.17728@fed1read03...
> > > Hi everyone,
> > >
...

> > > I have several PDF files that I would like to merge into one PDF and
add
> > > a watermark. I would like to do this with a batch command.

> Can this be done in the PS language and then PDF'd?

Yes, assuming you have your original documents in PS format.

---snip---

%!PS

<<
/BeginPage {
save 200 100 moveto 60 rotate
/Times-Roman findfont 140 scalefont setfont
0.9 setgray (Watermark) show
restore
}
>> setpagedevice

(c:\\temp\\file1.ps) run
(c:\\temp\\file2.ps) run
(c:\\temp\\file3.ps) run

% etc

---snip---

works fine for me using Acrobat Distiller.

--
Roger


Kevin Brault

unread,
Jul 27, 2003, 12:38:13 AM7/27/03
to
This worked perfectly ..... Thank you very much Roger.


I have two other questions;

1.) When I add the watermark, Adobe Acrobat Reader 6.0 will always show the
document in portrait orientation. With out the watermark it will show it in
the orientation the parent application created it in (i.e. "B" size is shown
landscape). The latter is preferred. Can this be fixed in the below code?

2.) Is there a way to have the watermark mark always appear in a certain
position regardless of the page size (i.e. always centered regardless if the
page size is A3, B, Letter, etc).


Thanks again for everyone's help.


Kevin

"Roger Willcocks" <rk...@rops.org> wrote in message

news:bfudic$smj$1$8300...@news.demon.co.uk...

Helge Blischke

unread,
Jul 28, 2003, 10:00:11 AM7/28/03
to
Kevin Brault wrote:
>
> This worked perfectly ..... Thank you very much Roger.
>
> I have two other questions;
>
> 1.) When I add the watermark, Adobe Acrobat Reader 6.0 will always show the
> document in portrait orientation. With out the watermark it will show it in
> the orientation the parent application created it in (i.e. "B" size is shown
> landscape). The latter is preferred. Can this be fixed in the below code?
Yes, see below (tell distiller not to rotate any pages)

>
> 2.) Is there a way to have the watermark mark always appear in a certain
> position regardless of the page size (i.e. always centered regardless if the
> page size is A3, B, Letter, etc).
Yes, see the other example of BeginPage below

>
> Thanks again for everyone's help.
>
> Kevin
>
> "Roger Willcocks" <rk...@rops.org> wrote in message
> news:bfudic$smj$1$8300...@news.demon.co.uk...
> > "Kevin Brault" <kevinj...@hotmail.com> wrote in message
> > news:6zvUa.27006$Ne.5155@fed1read03...
> > >
> > > news:bftkvl$pti$1$8300...@news.demon.co.uk...
> > > >
> > > > "Kevin Brault" <kevinj...@hotmail.com> wrote in message
> > > > news:Y6oUa.26779$Ne.17728@fed1read03...
> > > > > Hi everyone,
> > > > >
> > ...
> > > > > I have several PDF files that I would like to merge into one PDF and
> > add
> > > > > a watermark. I would like to do this with a batch command.
> >
> > > Can this be done in the PS language and then PDF'd?
> >
> > Yes, assuming you have your original documents in PS format.
> >
> > ---snip---
> >
> > %!PS
> >
> > <<
> > /BeginPage {
> > save 200 100 moveto 60 rotate
> > /Times-Roman findfont 140 scalefont setfont
> > 0.9 setgray (Watermark) show
> > restore
> > }
> > >> setpagedevice
/setdistillerparams where
{pop}
{userdict/setdistillerparams {pop} put}ifelse
<<
/AutoRotatePages /None
>>setdistillerparams

> >
> > (c:\\temp\\file1.ps) run
> > (c:\\temp\\file2.ps) run
> > (c:\\temp\\file3.ps) run
> >
> > % etc
> >
> > ---snip---
> >
> > works fine for me using Acrobat Distiller.
> >
> > --
> > Roger
> >
> >

The other example:

<<
/BeginPage
{
pop
gsave
/_WM_str (Confidential) def
/Courier [30 0 0 40 0 0] selectfont
/DeviceRGB setcolorspace
0.6 0.8 1 setcolor
currentpagedevice/PageSize get aload pop
2 div exch 2 div exch translate 45 rotate
newpath
_WM_str stringwidth pop 2 div neg 0 moveto
_WM_str show
grestore
}bind
>>setpagedevice

Good luck,

Helge

--
H.Bli...@srz-berlin.de
H.Bli...@srz-berlin.com
H.Bli...@acm.org

Roger Willcocks

unread,
Jul 28, 2003, 11:00:37 AM7/28/03
to
"Kevin Brault" <kevinj...@hotmail.com> wrote in message news:<TGIUa.27719$Ne.15361@fed1read03>...
> This worked perfectly ..... Thank you very much Roger.


First off there's a small error in the BeginPage code above: it should
pop one argument from the stack (it's the current page count):

/BeginPage {
pop save 200 100 moveto 60 rotate


/Times-Roman findfont 140 scalefont setfont
0.9 setgray (Watermark) show
restore
}
>> setpagedevice

>

> I have two other questions;
>
> 1.) When I add the watermark, Adobe Acrobat Reader 6.0 will always show the
> document in portrait orientation. With out the watermark it will show it in
> the orientation the parent application created it in (i.e. "B" size is shown
> landscape). The latter is preferred. Can this be fixed in the below code?
>


Without more details of your pages and environment (how are you
distilling the files?) it's difficult to diagnose your problem. The
most likely answer is that the BeginPage definition is clobbering an
existing one. The question is, where did it come from?

The following may do the trick:

<<
/BeginPage {
null exec


save 200 100 moveto 60 rotate
/Times-Roman findfont 140 scalefont setfont
0.9 setgray (Watermark) show
restore

} dup 0 currentpagedevice /BeginPage get put
>> setpagedevice


> 2.) Is there a way to have the watermark mark always appear in a certain
> position regardless of the page size (i.e. always centered regardless if the
> page size is A3, B, Letter, etc).
>
>

You can get the current page size using currentpagedevice, and use
that to rotate and scale your watermark.

>
> Thanks again for everyone's help.
>
>
> Kevin
>

--
Roger

0 new messages