Repeat, transparent and background watermark every pages

10,188 views
Skip to first unread message

Camille Croizy

unread,
Oct 23, 2014, 5:29:42 AM10/23/14
to dom...@googlegroups.com
Hi,

I'm french and I have a problem to generate a PDF with a transparent watermark in background on every pages.
I used dompdf 0.6.1 : https://github.com/dompdf/dompdf/releases/tag/v0.6.1 and my website is based on Joomla! 3.

I've succeed to add a watermark in background but not on every pages.

In my HTML file I've added :
<div id="watermark">watemark</div>

And I've added also :
<style>
#watermark {
position: fixed;
top: 35%;
left: 105px;
transform: rotate(45deg);
transform-origin: 50% 50%;
opacity: .3;
font-size: 120px;
color: white;
width: 480px;
text-align: center;
background-color: black;
}
</style>

But it's works only for the first page...
I read a lot of topics where this code works very well but it doesn't works for me and I don't find why.

Someone can help me ?

Thank you and I'm sorry for my english.

BrianS

unread,
Oct 23, 2014, 11:35:41 AM10/23/14
to dom...@googlegroups.com
It may help to see the full HTML. I created a simple page with what you provided and it displays as expected. So the issue may be a conflict elsewhere in the HTML or CSS.

Camille Croizy

unread,
Oct 29, 2014, 6:16:35 AM10/29/14
to dom...@googlegroups.com
Thank you for your quick answer. I'm sorry, I was waiting for an email to prevent me...

Your test works on several pages in the same PDF ?

I've attached my file HTML (I've clean it a little bit), you see something wrong ?

Thank you very much for your help.

I'm sorry again for my english.
test-dompdf.html

BrianS

unread,
Oct 30, 2014, 11:57:04 PM10/30/14
to dom...@googlegroups.com
I'm not sure what's going on, but it's not related to the transform. Just having a fixed-position element inside another element doesn't seem to be working. Moving the element out to the root of the document seems to fix things. I'm not sure if this is a bug or not ... Safari exhibits the same behavior when printing the document. I'll have to review the CSS spec to see if this is by design. In the meantime you'll have to place fixed-position content at the top level of the document hierarchy (i.e. it's parent should be the body element).

Camille Croizy

unread,
Nov 3, 2014, 6:18:14 AM11/3/14
to dom...@googlegroups.com
It's works !!! Thank you very much !!
I tried many tests but not change the position of my watermark in my DOM HTML... Thank you !

I just have another problem in the pdf : the content is truncated (see attached pdf) between the 2 pages.
I suppose it's a CSS problem again ?

Thank you for your help.
pdf-generate.pdf

Hermann Herz

unread,
Nov 5, 2014, 3:41:26 AM11/5/14
to dom...@googlegroups.com
You could test to add a 

page-break-inside: avoid;

into your ul "image-gallery" class?!

Camille Croizy

unread,
Nov 5, 2014, 4:52:24 AM11/5/14
to dom...@googlegroups.com
Thank you for your answer.

If I add page-break-inside into my ul .image-gallery, my list is not anymore truncated but it is not visible.
However, the space to show the list is present. You can see it in the attached pdf.

I've tried to add several attributes as : position, display, float, opacity, z-index, ...
I don't understand what it happens.

You have any ideas ?
pdf-test.pdf

Hermann Herz

unread,
Nov 7, 2014, 8:59:03 AM11/7/14
to dom...@googlegroups.com
sorry, Brian have you any further ideas?

BrianS

unread,
Nov 8, 2014, 10:22:59 AM11/8/14
to dom...@googlegroups.com
First, don't change the display type of images. dompdf has trouble when you do that. If you want to change how images flow with the document wrap them in another element.

Second, avoid inline-block except at the inline level (e.g. where you might normally use a span element). We need to improve support for that styling.

That being said, I could not get the list to display correctly. Using page-break-inside: avoid works but pushes the list to a new page, which I'm guessing is non-optimal. With other styling I was, at best, just able to reproduce the results you got. I'm not sure why dompdf is having such trouble with this layout, I'll have to look at it some more.

Camille Croizy

unread,
Nov 19, 2014, 3:23:07 AM11/19/14
to dom...@googlegroups.com
Thank you a lot !
I've removed the display on all images and now it works !

Thank you again for your time.

Uthayak kumar

unread,
Feb 26, 2018, 10:17:01 AM2/26/18
to dompdf
Hi Camille Croizy,

Even I am facing the same issue, when I was searching for a solution I found this group.

When I print the page, I am unable to see watermark in all the pages. It is working only on first page, do you have any solution for this?. 

BrianS

unread,
Mar 28, 2018, 9:42:53 PM3/28/18
to dompdf
This is a fairly old thread, I'd suggest starting a new one. Supply some sample HTML so we can see what you're trying.

Muhammad Hizbullah

unread,
Jun 11, 2019, 8:44:09 AM6/11/19
to dompdf
hello BrianS, can you help me. i have a problem with repeat watermark in every page

Muhammad Hizbullah

unread,
Jun 11, 2019, 8:44:09 AM6/11/19
to dompdf
this's my code


On Thursday, March 29, 2018 at 8:42:53 AM UTC+7, BrianS wrote:
kwitansi.html

BrianS

unread,
Jun 22, 2019, 8:15:16 PM6/22/19
to dompdf
Do you have a sample of the PDF output? Also, it would help to see the actual HTML parsed rather than the PHP template. Your code also links to some additional CSS (app.css, plus an @include call) that could be affecting the rendering.

I'll note one potential issue. Styling some of your table elements with display: block is going to be problematic for Dompdf to render correctly. And seems an unnecessary complication to your layout. Particularly for Dompdf.
Reply all
Reply to author
Forward
0 new messages