callegar / LaTeX-draftwatermark

The "draftwatermark" package extends LaTeX providing a means to add a textual, light gray watermark on every page or on the first page of a document. Typical usage may consist in writing words such as "DRAFT" or "CONFIDENTIAL" across document pages. The package may remind in some sense "draftcopy" by Dr. Juergen Vollmer, but its implementation is much lighter (as the reduced code footprint shows) and does not rely on postscript specials, making the package fully compatible with pdfLaTeX. The package depends on package "everypage" by the same author.
15 stars 6 forks source link

Watermark is incorrectly placed on the foreground of included PDFs #17

Closed krishnakumarg1984 closed 8 months ago

krishnakumarg1984 commented 5 years ago

When including external PDFs using the includepdf directive of the pdfpages package, the watermarks placed by draftwatermark are incorrectly on the foreground, rather than on the background.

This is a fairly general case for PhD theses. For example,

It is not acceptable to be watermarking on the foreground of these PDFs as readability is severely affected.

callegar commented 5 years ago

Draftwatermark by current standards has many limitations. One of them is that you cannot fine control the "depth" where the watermark is placed. Fixing this issue would require a thorough rewrite of the code, that unfortuntately cannot be on my radar due to lack of time. My suggestion is to use Koma script scrlayer to achieve the desired goals in all cases where draftwatermark is currently insufficient.

callegar commented 4 years ago

Can you please provide a little testcase? I am currently updating the draftwatermark package and if possible I would like to take the occasion to look into this matter.

callegar commented 3 years ago

A new version of draftwatermark is out (release 3.0). On new LaTeX formats (Autumn 2020) it uses a different mechanism to put the watermark on the page. This should assure that the watermark is actually always on the background. If you have a new enough LaTeX system, can you give it a try and report back?

jamesg-mit commented 3 years ago

Hi Sergio, Thank you very much for your contributions and the draftwatermark package.

I believe I have a reasonable MWE test case that shows the issue when pdfpages is used with draftwatermark. Here the watermark is placed on top of the included PDF but behind other files.

MWE tex file

\documentclass[]{article}

%Packages 
\usepackage{pdfpages}
\usepackage[stamp,color=red!10]{draftwatermark}
\usepackage{lipsum}
\usepackage[T1]{fontenc} % use T1 encoded fonts in output -- 256 glyphs vs. 128, also <> symbols work
\usepackage[utf8]{inputenc} % allow for utf8 encoding in the .tex files
\usepackage{lmodern} % use latin modern font (updated replacement vs. cm), have to load AFTER fontenc

\begin{document}
\textbf{Watermark is under the text}
\lipsum[1-3]
\textbf{In the following page, the watermark is over the inserted PDF:}
\clearpage

\includepdf[pages={1-},         %Select pages from 3 onward to end
    scale=0.86,                 %Tweak scale to fit within margin of output. 0.86 is max to fit
    trim=1in 1in 1in 1in, clip, %[left bot right top]: Clip off margins of source doc, 1" margins
    landscape=false, angle=0,   %don't use landscape or rotate
    frame=true,                 %add frame (may be turned off)
    pagecommand={}]             %Needed to prevent empty page format (which deletes template headers/footers)
    {test_include.pdf}   %Included file
\end{document}

Test PDF to include test_include.pdf

Resulting PDF watermark_example.pdf Build info:


pdfTeX, Version 3.141592653-2.6-1.40.23 (MiKTeX 21.10) (preloaded format=pdflatex 2021.10.12)
pdfpages.sty    2021/03/06 v0.5t Insert pages of external PDF documents (AM)
draftwatermark.sty    2020/12/08 3.0 Put a gray textual watermark on document pages```
dseddah commented 1 year ago

Hi, thanks for this very cool package. It would very cool to have an option to make sure that the watermark would be on top of everything. For example, i'm having imported graphs as pdf images through includegraphics and the watermark is below the image but above the text :(

callegar commented 8 months ago

@jamesg-mit

With a long delay, a fix/workaround is in the works.

In case you are interested in som inner details, I hoped that pdfpages would have moved to use the new LaTeX hooks framework directly rather than depending on eso-pic which could have enabled a more robust solution to the problem. As is, it is unclear to me if placing a workaround in draftwatermark could break something else depending on eso-pic.

As a temporary workaround for your case, please try adding

\DeclareHookRule {shipout/background}{draftwatermark}{<}{eso-pic}

before \begin{document}

callegar commented 8 months ago

Workaround is in R3.3

jamesg-mit commented 8 months ago

@callegar I really would like to thank you. The new package and work around work great for my application.

I also noticed that I can flip the less-than to greater-than operator to force the watermark on top and thought that was pretty neat.