Skip to main content
Participant
July 14, 2021
Answered

How to add transparent text watermark to PDF / PS file

  • July 14, 2021
  • 2 replies
  • 2256 views

My environment is Linux. I want to do a program to add a print watermark. The program will process the file before the printed PDF is sent to the printer, add watermark information (some identification text), and then send it to the printer for printing. But now the text added by PS script can't achieve the transparent effect, and will cover the body of the document. How to realize this? It's better to have a demo.

    This topic has been closed for replies.
    Correct answer Test Screen Name

    Ok, that uses a GhostScript extension - not a standard PostScript feature. May be a GhostScript limition. Or, you aren't feeding it to GhostScript but to something else.

    2 replies

    Test Screen NameCorrect answer
    Legend
    August 4, 2021

    Ok, that uses a GhostScript extension - not a standard PostScript feature. May be a GhostScript limition. Or, you aren't feeding it to GhostScript but to something else.

    Chang5C75Author
    Participant
    August 4, 2021

    OK, I see. Thank you very much for your reply.

    Legend
    August 3, 2021

    PostScript doesn't support transparency.

    Chang5C75Author
    Participant
    August 4, 2021

    In fact, I found a PS script to generate transparent effect, but I can't combine it with other PDF.

    Examples are as follows:

    %!PS
    %   Postscript that uses Ghostscript extensions to do simple transparency
    
    << /CompatibilityLevel 1.4 >> setpagedevice % in case we are going to pdfwrite
    
    % work around rectfill mapping directly to device fill_rectangle
    /rectfill {
      gsave 4 2 roll moveto 1 index 0 rlineto
      0 exch rlineto neg 0 rlineto closepath fill grestore
    } bind def 
    
    0 .pushpdf14devicefilter % depth .pushpdf14devicefilter -
         << >> clippath pathbbox newpath .begintransparencygroup
    
         .5 .setopacityalpha 1 .setshapealpha
    
         .5 .9 .2 setrgbcolor
         0 0 300 700 rectfill
        
         .2 .5 .9 setrgbcolor
         200 100 400 400 rectfill
    
         .9 .3 .1 setrgbcolor
    
         100 200 500 500 rectfill
         .endtransparencygroup
    .poppdf14devicefilter
    
    showpage
    quit