Is there a way to overlay some text over top of an image (without using a Site object) using Infragistics Document engine?
I would want the background of the text to be transparent, such that I could see the image behind the text.
In my case I was just whipping together a quick test, so I didn't bother storing the variable outside of the one place that I used it. If you're going to be doing this in more than one place, I would create one instance of the IDrawing implementation instance and reuse it as often as possible, for efficiency.
text.Background = new Background(Infragistics.Documents.Graphics.Brushes.White, new MyDrawing());...
...
private class MyDrawing : IDrawing{ public void OnDraw(Infragistics.Documents.Graphics.IGraphics graphics, float x, float y, float width, float height) { Infragistics.Documents.Graphics.Image image = new Infragistics.Documents.Graphics.Image("wave_1280_1024.jpg"); graphics.DrawImage(image, x, y, width, height); }}
I did not realize you could do this:
new MyDrawing()
Thank you for this reply, Matt.
Let me take a few minutes to read and understand your post and I'll come back with any questions.
Tom
There's not a really simple way to do this, since without the ISite object, everything will be positioned sequentially. What you could do is create a new Background object on the IText element that you are adding your content to. In the constructor for the Background, you would pass in an instance of a class that you write that implements IDrawing, so you can draw whatever you want into the background, such as:
Report r = new Report();IText text = r.AddSection().AddText();text.Background = new Background(Infragistics.Documents.Graphics.Brushes.White, new MyDrawing());text.AddContent("This is some text");r.Publish("Test.pdf", FileFormat.PDF);
Naturally, you would have to replace the name of the image with whatever is appropriate. You also might want to center the image, not stretch it, etc, but with the IDrawing interface you have a lot more flexibility.
-Matt