Search code examples
cssasp.net-mvcwatermarkrotativa

Watermark in Pdf using css or Rotativa (PDF generater)


I am using rotativa for generate PDF in MVC.

I want watermark in all pages of PDF but unfortunately I am not achieving this.

I have researched also for rotativa but can't find any proper solution for this. And then I have tried this using CSS.

I have tried this

CSS

   #background {
            position: absolute;
            display: block;
            min-width: 100%;
            opacity: 0.5;
            text-align: center;
            background-color: transparent;
            padding-top:50%;
        }
        #bg-text {
            color: lightgrey;
            font-size: 120px;
            transform: rotate(300deg);
            -webkit-transform: rotate(300deg);
            opacity: 0.9;
            filter: alpha(opacity=50);
            background-color: transparent;
        }

HTML

 <div id="background">
            <p id="bg-text">Draft</p>
        </div>

It's works fine for first page of PDF. And I want this in all pages of PDF. Please suggest me a proper solution for this problem of watermark.

Any solution will be appreciable using CSS or using rotativa


Solution

  • I have resolved my problem by following

    Html

    <div class="watermark" style="background: url('../Images/watermark.png');"></div>
    

    CSS

     .watermark {
                height: 95%;
                width: 90%;
                position: absolute;
                top: 0;
                bottom: 0;
                right: 0;
                left: 0;
                background-repeat: repeat-y;
                z-index: 9999;
                opacity: 0.2;
            }