We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Floating Box ZIndex not working?


I’m having trouble getting the Zindex to work properly. I’m trying to add a watermark to my pdf and used the example in the documentation. I was able to show the watermark and position it properly, but it’s being rendered in front of the text. No matter what value I use for the ZIndex, it’s still in front of the text. If it helps, it does get put behind checkboxes and radio buttons. Here’s a snippet of my code:

Dim pdf1 As Pdf = New Pdf()

Dim license As Aspose.Pdf.License = New Aspose.Pdf.License

Dim image2 As Aspose.Pdf.Image = New Aspose.Pdf.Image()
image2.ImageInfo.File = "http://www.rdtinc.com/images/logos/cep_logo_background.gif"
image2.ImageInfo.ImageFileType = ImageFileType.gif
image2.ImageScale = 1f

Dim watermark1 As FloatingBox = New FloatingBox()
watermark1.left = -65
watermark1.top = 75
watermark1.ZIndex = -100


Dim sec1 As Section = pdf1.Sections.Add()

Dim myText = New Text(sec1, "Instead of saving labor, the new gadgets shift it, from store employees to shoppers. Users weigh, scan, and bag their own purchases, preferably in reusable cloth bags, priced at 99 cents each. Good for the environment, and for the bottom line. No wonder the bags are green. When I asked Stop & Shop spokesman Robert Keane about how all this technology will reduce labor costs, he deftly sidestepped the question. This is something to really offer the customer choices, he said. And of course, he's right. After years as a faithful Shaw's customer, I switched to the Stop & Shop in Quincy because its grocery tech gets me in and out of the store so much faster. Besides, it's cool. Especially the device at the heart of the Stop & Shop system, the Scan It personal scanner. Shaped like a bar of soap with a pistol grip, the Scan It has been deployed in about 90 Stop & Shops, the first large-scale deployment of the system anywhere in the world. Scan It is a lot sleeker and simpler than the first personal scanners introduced by Stop & Shop in 2005. The old device, called Shopping Buddy, was about as big and heavy as a laptop computer and overburdened with features shoppers didn't need, like a digital map of the store or games to keep children occupied while their parents shopped.")


Thanks for your help!

Hello Dennis,

Please add the FloatingBox to paragraphs collection of Section, in a same manner as you added the text object. Floatingbox should be added before text object. Place following code lines, before saving the Pdf file.


Let me share some thing related to Z-Index. you can adjust the Z-order of floating box when you have more than one Floatingbox objects. A floating box with larger ZIndex will be placed over the floating box with smaller ZIndex. So it has no effect here.


This works, but only shows on the first page now. Is there anyway to have this repeat on every page?

When I add to the watermarks collection it repeats on every page, but in front of the text.



Hello Dennis,

Please use IsWatermarkOnTop property of Pdf class that is used to set the watermark over top or at the behind the contents of the pdf file. Please add following line of code, to your original code snippet. Please ignore code snippet provided in pervious post.

pdf1.IsWatermarkOnTop = False

For more information kindly visit IsWatermarkOnTop

This is perfect!

Thanks for your help.