Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created July 17, 2015 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/b209e1461a2d82a90627 to your computer and use it in GitHub Desktop.
Save bjoerntx/b209e1461a2d82a90627 to your computer and use it in GitHub Desktop.
private void InsertWatermarkImages()
{
// remove all existing watermarks
RemoveWatermarkImages(textControl1);
foreach (TXTextControl.Page page in textControl1.GetPages())
{
// create a new watermark image
Bitmap bmp = CreateDraftImage();
// create a new TXTextControl.Image object and mark
// as watermark
TXTextControl.Image img = new TXTextControl.Image(bmp);
img.Name = "Watermark";
img.Sizeable = false;
img.Moveable = false;
// calculate the location to center the image
Point pImageLocation = new Point(
(page.Bounds.Width / 2) - (PixelToTwips(bmp.Size.Width)) / 2,
(page.Bounds.Height / 2) - (PixelToTwips(bmp.Size.Height)) / 2);
// add the image to the page
textControl1.Images.Add(
img,
page.Number,
pImageLocation,
TXTextControl.ImageInsertionMode.BelowTheText);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment