0

I have a visualforce pdf...the requirement is to put "Draft" watermark on all pages of vf document if quote status is either pending or awaiting approval. I tried to implement this by adding watermark tag in style in head block.

<head>
           
            <style>
                
                .watermark {
                    background-repeat: repeat;
                    background-image: url("{!$Label.QuoteDraftURL}");
                    background-position: center;
                }
                .watermark-img{
                    position: absolute;
                    width: 90%;
                    height: 90%;
                    top: 20%;
                    left: 10%;
                }
               
                
            </style>
        </head>

then in body conditionally rendering it in output panel like below

     <body>
    
                <apex:outputPanel styleClass="watermark-block" layout="block" rendered="{!IF(OR(qObj.SBQQ__Status__c='Pending',qObj.SBQQ__Status__c='Awaiting Approval'),true,false)}">
                    <img class="watermark-img" src="{!$Label.QuoteDraftURL}"/>
                </apex:outputPanel>

<!--remaining code/table-->
    </body>

but this way the watermark only comes on 1 page. How to make sure the watermark is present on all pages conditionally?

2

1 Answer 1

0

With the continuation of the above comment , the watermark text is rendered using apex:outputText and with the styleClass set to "watermark-text" it is achievable.

<head>
    <style>
        @page {
            @top-left {
                content: element(header);
            }
        }
     
        .watermark-text {
            font-size: 48px; /* Adjust the font size as needed */
            color: #999999; /* Adjust the color as needed */
        }
    </style>
</head>

Inside the body :

<body>
    <apex:outputPanel id="header" layout="none" rendered="{!OR(qObj.SBQQ_Statusc == 'Pending', qObj.SBQQStatus_c == 'Awaiting Approval')}">
        <div class="watermark">
            <apex:outputText styleClass="watermark-text">
                <apex:param value="Draft"/>
            </apex:outputText>
        </div>
    </apex:outputPanel>

    <!-- Remaining code/table -->
</body>

Also refer : How to use apex:outputText in Visualforce Page

Hope this helps !

1
  • I've never seen <apex:param> be used in outputText without a corresponding {..} placeholder in the outputText value=
    – cropredy
    Jun 7, 2023 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .