public override void Draw(PdfDisplayBox box, CoreGraphics.CGContext context) { // Draw original content base.Draw(box, context); using (context) { // Draw watermark underlay UIGraphics.PushContext(context); context.SaveState(); var pageBounds = this.GetBoundsForBox(box); context.TranslateCTM(0.0f, pageBounds.Size.Height); context.ScaleCTM(1.0f, -1.0f); context.RotateCTM((float)(Math.PI / 4.0f)); Console.WriteLine($"{pageBounds}"); var attributes = new UIStringAttributes() { ForegroundColor = UIColor.FromRGBA(255, 0, 0, 125), Font = UIFont.BoldSystemFontOfSize(84) }; var text = new NSAttributedString("WATERMARK", attributes); text.DrawString(new CGPoint(250, 40)); context.RestoreState(); UIGraphics.PopContext(); } }
public override void Draw(PdfDisplayBox box) { //base.Draw (box); CGRect sourceRect = new CGRect(0, 0, 0, 0); CGRect topHalf; CGRect destRect; // Drag image. // ........... // Source rectangle. sourceRect.Size = PdfImage.Size; // Represent the top half of the page. topHalf = GetBoundsForBox(box); Utility.ColorWithHexColorValue("#ffffff", 1.0f).Set(); NSGraphics.RectFill(topHalf); // Scale and center image within top half of page. destRect = sourceRect; destRect.Height -= 120; destRect.Y += 60; // Draw. //Console.WriteLine("left:{0},top:{1},width:{2},height:{3}",destRect.X,destRect.Y,destRect.Width,destRect.Height); PdfImage.DrawInRect(destRect, new CGRect(0, 0, 0, 0), NSCompositingOperation.SourceOver, 1.0f); // Draw name. // ........... destRect = GetBoundsForBox(box); destRect.Y = destRect.Height - 44.0f; destRect.Height = 34.0f; destRect.X = 30.0f; destRect.Width -= 60.0f; // Draw label. NSStringAttributes attributes = new NSStringAttributes(); attributes.Font = NSFont.SystemFontOfSize(11); Label.DrawInRect(destRect, attributes); // Draw name. // ........... destRect = GetBoundsForBox(box); destRect.Y = 10.0f; destRect.Height = 17.0f; destRect.X = 30.0f; destRect.Width -= 60.0f; PageFooter.DrawInRect(destRect, attributes); }
public override CGRect GetBoundsForBox(PdfDisplayBox box) { return(base.GetBoundsForBox(box)); }