pustakakoran

PDF Watermark GhostScript

Nov 5th, 2017
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Perintah bash:
  2. gs -q -dNOPAUSE -dSAFER -dBATCH -sOutputFile=watermarked3ok.pdf -sDEVICE=pdfwrite logo2.txt -f tambahinlogo.pdf
  3.  
  4. Penjelasan:
  5. 1. tambahinlogo.pdf >> file asli
  6. 2. watermarked.pdf >> file hasil + waterwark
  7. 3. logo2.txt >> file berisi kode tekx waterwark, isi kodenya adalah:
  8.  
  9. /watermarkText { (WATERMARK TEXT) } def
  10. /watermarkFont { /Helvetica-Bold 72 selectfont } def
  11. /watermarkColor { .75 setgray } def
  12. /watermarkAngle { 45 } def
  13.  
  14. /pageWidth { currentpagedevice /PageSize get 0 get } def
  15. /pageHeight { currentpagedevice /PageSize get 1 get } def
  16.  
  17. <<
  18. /EndPage {
  19. 2 eq { pop false }
  20. {
  21. gsave
  22. watermarkFont
  23. watermarkColor
  24. pageWidth .5 mul pageHeight .5 mul translate
  25. 0 0 moveto
  26. watermarkText false charpath flattenpath pathbbox
  27. 4 2 roll pop pop
  28. 0 0 moveto
  29. watermarkAngle rotate
  30. -.5 mul exch -.5 mul exch
  31. rmoveto
  32. watermarkText show
  33. grestore
  34. true
  35. } ifelse
  36. } bind
  37. >> setpagedevice
  38.  
  39. 4. Hasilnya nanti file pdf berisi watermark dengan tulisan WATERMARK TEXT melintang miring di setiap halaman PDF
RAW Paste Data