15 Replies Latest reply: Jun 20, 2013 6:40 AM by abeddie RSS

    make text watermark on top of background image

    Ayman.. Community Member

      Hi ,

       

      im using the following code that i found in the internet to create a watermark for PS file

      %!PS

      <<

      /BeginPage {

      save 200 100 moveto 60 rotate

      /Times-Roman findfont 140 scalefont setfont

      0.9 setgray (DRAFT) show

      restore

      }

      >> setpagedevice

       

      the problem is that when i have an image background the watermark is not appearing ontop of it

       

      how can i make the watermark text appear ontop of the image ?

       

      thanks

       

      the image section is as follow

       

      302 618 1829 1641 CL

      GS 302 618 translate 1829 1641 scale

      save

      1829 1641 1829 1641 8 0 -0 IM

      ffffffffffff8dff19eaffffffffffffffffffffffffffff0aff19eaffffffff

      ..............................

      e1ff36eaffffffffffffffffffffffffedff36eaffffffffffffffffffff71ff

      restore

      GR

        • 1. Re: make text watermark on top of background image
          abeddie Community Member

          BeginPage executes at the beginning or before your image. Change it to  EndPage which executes after.

          • 2. Re: make text watermark on top of background image
            Ayman.. Community Member

            thank u ,

             

            i tried to replace BeginPage with EndPage

             

            but it doesnt work , i got an error when opening the file using ghostview

             

            here is the log

             

            --- Begin offending input ---

            72 ,1 \344\350\351\361\370\341\351\360\345\340\344 \352\370\343)SH

            1203 194 1111 53 CL

            2024 237 MT

            (4353701 \344\360\360\362\370)SH

            1203 247 1111 53 CL

            2000 290 MT

            (09-7780778 :\354\350)SH

            46 141 1315 53 CL

            46 188 MT

            %%IncludeResource: font David-Bold-ISOLatinHebrew

            /David-Bold-ISOLatinHebrew 11 1 FN

            (1 University Road, POB 808)SH

            SHP

            %%PageTrailer

            EP

            %%Trailer

            restore

            %%Pages: 1

            %%EOF

             

             

            --- End offending input ---

            file offset = 0

            gsapi_run_string_continue returns -101

            Unrecoverable error: typecheck in if

            Operand stack:

                --nostringval--  2  --nostringval--

             

             

             

             

             

             


            • 3. Re: make text watermark on top of background image
              abeddie Community Member

              <<

                /EndPage

                {

                  pop pop save initgraphics

                 /Times-Roman 140 selectfont

                 200 100 moveto

                 60 rotate

                 (DRAFT) show restore

                 true

                }

              >> setpagedevice

               

              .9 0 0 setrgbcolor

              72 72 500 600 rectfill

              showpage

               

              Instead of an image there is a red rectangle

              • 4. Re: make text watermark on top of background image
                Ayman.. Community Member

                thank u very much

                 

                but i still have 2 problems

                 

                1. the text is not transparent

                 

                i wrote  "0.9 setgray (DRAFT) show restore"

                 

                but it show a light gray not transparent

                 

                2. when i print the document its print 5 blank docs with DRAFT watermark ?!

                 

                 

                thanks

                • 5. Re: make text watermark on top of background image
                  abeddie Community Member

                  PostScript used an opaque write so the light gray on top knocked out

                  what was underneath. The following requires setoverprint and setoverprintmode which may not be supported in a very old printer. Also cmyk colorspace is needed so the is used in place of setgray and setrgbcolor. This

                  printed page 1 with a cyan rectangle with the text DRAFT in light gray but that

                  text is still mostly cyan. It is not light gray and white as it did not knock out the

                  cyan. It also prints page 2 with just a light hray DRAFT and no rectangle. Try

                  this standalone to seee if setoverprint setoverprintmode works on your printer.

                   

                  %!

                  <<

                    /EndPage

                    {

                      pop pop save initgraphics

                      true dup setoverprint setoverprintmode

                      /Times-Roman 140 selectfont

                      200 100 moveto

                      60 rotate

                      .9 setgray

                      0 0 0 .1 setcmykcolor

                      (DRAFT) show restore

                      true

                    }

                  >> setpagedevice

                   

                  1 0 0 0 setcmykcolor

                  72 72 500 600 rectfill

                  showpage

                   

                  showpage

                  • 6. Re: make text watermark on top of background image
                    Ayman.. Community Member

                    first of all i want to thank u that u r helping me , for me this PS language is like chinease there is no chance that i can learn it

                     

                    regarding the last sample that u sent , in ghostview i am still seeing the gray text covering the cyan and when i try to print the file it didnt printed !

                     

                     

                    if there is not transparent text in PS , can the text be with pattern that doesnt cover the text underneath or can the text be hollow for example ? or if u have any bettter idea to deal with this problem ?

                     

                    i have a solution but its not practical : i changed the PS to PDF using ps2pdf and i have a code that add the watermark perfectly to the PDF the problem is when converting the PDF back to PS using pdf2ps the file size is very large !!

                    • 7. Re: make text watermark on top of background image
                      abeddie Community Member

                      This one does the text outline allowing what is underneath to show.

                       

                      %!

                      <<

                        /EndPage

                        {

                          pop pop save initgraphics

                          /Times-Roman 140 selectfont

                          200 100 moveto

                          60 rotate

                          .9 setgray

                          (DRAFT) false charpath

                          2 setlinewidth

                          stroke

                          restore

                          true

                        }

                      >> setpagedevice

                       

                      1 0 0 0 setcmykcolor

                      72 72 500 600 rectfill

                      showpage

                      • 8. Re: make text watermark on top of background image
                        Ayman.. Community Member

                        Hi ,

                         

                        now its looks great and the underneath text is shown

                         

                        but i still have the printing problem !!

                         

                        when i print the file without ur code it prints 1 file but when i add urs code it prints 3 or 4 blank pages with DRAFT text ?!

                         

                        i tried 2 printers and they did the same thing

                         

                        im printing using the command

                        /usr/ucb/lpr -P printer_name file_name

                        • 9. Re: make text watermark on top of background image
                          abeddie Community Member

                          %! new version

                          <<

                            /EndPage

                            {

                              pop 0 eq

                              {

                                save initgraphics

                                /Times-Roman 140 selectfont

                                200 100 moveto

                                60 rotate

                                .9 setgray

                                (DRAFT) false charpath

                                2 setlinewidth

                                stroke

                                restore

                                true

                              }

                              {

                                false

                              } ifelse

                            }

                          >> setpagedevice

                           

                          1 0 0 0 setcmykcolor

                          72 72 500 600 rectfill

                          showpage

                          • 10. Re: make text watermark on top of background image
                            Ayman.. Community Member

                            Hi ,

                             

                            it seems that its working fine for ur sample , i printed it and its print one page

                             

                            but the problem is with my files ?!

                             

                            what could be the problem ?

                             

                            here is a link to a sample file that when printed its print 3 extra blank pages

                             

                            https://skydrive.live.com/redir?resid=10C4441C5F41E70E!269&authkey=!AOG2LeB53ZLNuNo

                             

                            thanks

                            • 11. Re: make text watermark on top of background image
                              abeddie Community Member

                              There are 2 device dependend level 1 command lines:

                               

                              0 statusdict /setpapertray get exec

                               

                              You can comment out both lines and try it. If you need those lines to select media from

                              a specific tray try moving the new EndPage code to after the second of those lines. Both

                              methods worked on my printer which gave 4 pages without the change.

                              • 12. Re: make text watermark on top of background image
                                Ayman.. Community Member

                                Hi ,

                                 

                                i tried ur suggestion of commenting out all the lines 0 statusdict /setpapertray get exe

                                 

                                but the problem now is when i have a report with more than one page its only show/print the first page ?!

                                 

                                i tried to put the code in many places after the 0 statusdict /setpapertray get exec but it doesnt work

                                 

                                i have for exmple a file with 5 pages and 5 sections as below ,

                                 

                                 

                                %%Page: 1 1

                                %%BeginPageSetup

                                %%BeginFeature: *PageSize Letter

                                 

                                %%EndFeature

                                %%BeginFeature: *InputSlot Upper

                                0 statusdict /setpapertray get exec

                                %%EndFeature

                                0 0.000 -3450.000 0 83.333 66.666 1.000 1.000 IP

                                %%EndPageSetup

                                initclip

                                ..........

                                ..........

                                %%PageTrailer

                                EP

                                %%Trailer

                                restore

                                %%Pages: 5

                                %%EOF

                                • 13. Re: make text watermark on top of background image
                                  abeddie Community Member

                                  %!

                                  % multi page test - add exch from prior version

                                  <<

                                    /EndPage

                                    {

                                      exch pop 0 eq

                                      {

                                        save initgraphics

                                        /Times-Roman 140 selectfont

                                        200 100 moveto

                                        60 rotate

                                        .9 setgray

                                        (DRAFT) false charpath

                                        2 setlinewidth

                                        stroke

                                        restore

                                        true

                                      }

                                      {

                                        false

                                      } ifelse

                                    }

                                  >> setpagedevice

                                   

                                  1 0 0 0 setcmykcolor

                                  72 72 500 600 rectfill

                                  showpage

                                   

                                  0 1 0 0 setcmykcolor

                                  72 72 500 600 rectfill

                                  showpage

                                   

                                  0 0 1 0 setcmykcolor

                                  72 72 500 600 rectfill

                                  showpage

                                  • 14. Re: make text watermark on top of background image
                                    Ayman.. Community Member

                                    Hi abeddie ,

                                     

                                    thank u very much its working now perfectly ur answers were professional and helpful

                                     

                                    can u tell me how to change the writing direction of the DRAFT word

                                     

                                    coz for landscape file its not in the correct direction

                                     

                                    is there a chance to write it from the upper left corner to the lower right corner ?!

                                    • 15. Re: make text watermark on top of background image
                                      abeddie Community Member

                                      Below is another sample you should be able to modify. It finds out what the page dimensions are

                                      in points 1/72 of an inch and puts them in pw and ph with a currentpagedevice. Then if pagewidth is

                                      greater thanpageheight (pw ph gt) it is landscape and uses a -30 degree rotate. If it is portrait the

                                      60 degree is still used. You can go a step further and calculate angles based on pw and ph instead

                                      of using fixed.

                                       

                                      %!

                                      <<

                                        /EndPage

                                        {

                                          currentpagedevice /PageSize get aload pop /ph exch def /pw exch def

                                          exch pop 0 eq

                                          {

                                            save initgraphics

                                            /Times-Roman 140 selectfont

                                            pw ph gt

                                            { % landscape start 3 inches from top left

                                              216 ph 216 sub moveto

                                              -30 rotate

                                            }

                                            { % portrait start 3 inches from bottom left

                                              216 216 moveto

                                              60 rotate

                                            } ifelse

                                       

                                            .9 setgray

                                            (DRAFT) false charpath

                                            2 setlinewidth

                                            stroke

                                            restore

                                            true

                                          }

                                          {

                                            false

                                          } ifelse

                                        }

                                      >> setpagedevice

                                       

                                      currentpagedevice /PageSize get aload pop /ph exch def /pw exch def

                                      1 0 0 0 setcmykcolor

                                      72 72 pw 144 sub ph 144 sub rectfill

                                      showpage

                                       

                                      0 1 0 0 setcmykcolor

                                      72 72 pw 144 sub ph 144 sub rectfill

                                      showpage

                                       

                                      0 0 1 0 setcmykcolor

                                      72 72 500 600 rectfill

                                      showpage