Set the plot background to white if not doing compare and transparent if doing a compare.

Add logic to exclude high level steps from those items included in the Replace Words list for substeps.
Removed event handlers for DSOFramer.  It appears that these no longer work for MSWord 2013.
New Watermark Logic
This commit is contained in:
Rich 2013-11-07 21:45:56 +00:00
parent f9ba96fdd8
commit 60dbbb6269
5 changed files with 208 additions and 127 deletions

View File

@ -11,6 +11,7 @@ namespace VG
public interface IVGOutput
{
float Scale { get;}
int DebugStatus { get; set; }
void DrawLine(Pen pn, float startx, float starty, float endx, float endy);
void DrawRectangle(Pen pn, RectangleF rectf);
void DrawEllipse(Pen pn, float cx, float cy, float dx, float dy);
@ -23,6 +24,12 @@ namespace VG
}
public partial class VGOut_Graphics: IVGOutput
{
private int _DebugStatus = 0;
public int DebugStatus
{
get { return _DebugStatus; }
set { _DebugStatus = value; }
}
private Graphics _VGOutput;
//public Graphics VGOutput
//{ get { return _VGOutput; } }
@ -36,7 +43,7 @@ namespace VG
public void DrawRectangle(Pen pn, RectangleF rectf)
{
_VGOutput.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
_VGOutput.FillRectangle(Brushes.Transparent, rectf.X, rectf.Y, rectf.Width, rectf.Height);
_VGOutput.FillRectangle(DebugStatus == 1 ? Brushes.Transparent : Brushes.White, rectf.X, rectf.Y, rectf.Width, rectf.Height);
_VGOutput.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
_VGOutput.DrawRectangle(pn, rectf.X, rectf.Y, rectf.Width, rectf.Height);
}
@ -57,6 +64,12 @@ namespace VG
}
public partial class VGOut_ITextSharp : IVGOutput
{
private int _DebugStatus = 0;
public int DebugStatus
{
get { return _DebugStatus; }
set { _DebugStatus = value; }
}
private PdfContentByte _VGOutput;
//public Graphics VGOutput
//{ get { return _VGOutput; } }

View File

@ -203,8 +203,8 @@ namespace Volian.Controls.Library
this._MyDSOFramer.Titlebar = false;
//if (_MyCount < 20)
// this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
this._MyDSOFramer.BeforeDocumentClosed += new AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEventHandler(_MyDSOFramer_BeforeDocumentClosed);
this._MyDSOFramer.OnSaveCompleted += new AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEventHandler(_MyDSOFramer_OnSaveCompleted);
//this._MyDSOFramer.BeforeDocumentClosed += new AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEventHandler(_MyDSOFramer_BeforeDocumentClosed);
//this._MyDSOFramer.OnSaveCompleted += new AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEventHandler(_MyDSOFramer_OnSaveCompleted);
//this._MyDSOFramer.LostFocus += new EventHandler(_MyDSOFramer_LostFocus);
//this._MyDSOFramer.GotFocus += new EventHandler(_MyDSOFramer_GotFocus);
//this._MyDSOFramer.Enter += new EventHandler(_MyDSOFramer_Enter);
@ -373,12 +373,19 @@ namespace Volian.Controls.Library
{
this.Select();
}
/// <summary>
/// If the user presses the save button, tell the file to save it's contents to the database
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e)
///// <summary>
///// If the user presses the save button, tell the file to save it's contents to the database
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//void _MyDSOFramer_OnSaveCompleted(object sender, AxDSOFramer._DFramerCtlEvents_OnSaveCompletedEvent e)
//{
// _MyLog.WarnFormat("_MyDSOFramer_OnSaveCompleted");
// Volian.Base.Library.vlnStackTrace.ShowStack("_MyDSOFramer_OnSaveCompleted");
// SaveDSO_Phase2();
//}
private void SaveDSO_Phase2()
{
// Unfortunately, the only way to handle view mode for DSO Framer is to not save.
if (PanelViewEditMode == E_ViewMode.View)
@ -418,12 +425,17 @@ namespace Volian.Controls.Library
tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text));
}
}
/// <summary>
/// Before a document closes check to see if it's contents should be saved.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e)
///// <summary>
///// Before a document closes check to see if it's contents should be saved.
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//void _MyDSOFramer_BeforeDocumentClosed(object sender, AxDSOFramer._DFramerCtlEvents_BeforeDocumentClosedEvent e)
//{
// SaveDSOPhase1();
//}
private void SaveDSO_Phase1()
{
try
{
@ -465,7 +477,7 @@ namespace Volian.Controls.Library
}
try
{
_MyDSOFramer.EventsEnabled = true;
//_MyDSOFramer.EventsEnabled = true;
_MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow;
}
catch (Exception ex)
@ -494,7 +506,8 @@ namespace Volian.Controls.Library
try
{
_MyDSOFramer.Save();
_MyDSOFramer_OnSaveCompleted(this, null);
SaveDSO_Phase2();
//_MyDSOFramer_OnSaveCompleted(this, null);
// These are handled in the method above
//LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument);
//MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName");
@ -524,7 +537,7 @@ namespace Volian.Controls.Library
return false;
}
//if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.MyItemInfo.TabTitle + "\r\n" + _MyDisplayTabItem.MyItemInfo.TabToolTip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.Text + "\r\n" + _MyDisplayTabItem.Tooltip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
if (MessageBox.Show("Save changes to " + _MyDisplayTabItem.Text + "\r\n" + _MyDisplayTabItem.Tooltip, "Document has Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
return SaveDSO();
return false;
}
@ -557,6 +570,7 @@ namespace Volian.Controls.Library
{
if (_MyDSOFramer != null)
{
SaveDSO_Phase1();
_MyDSOFramer.Close();
Controls.Remove(_MyDSOFramer);
components.Remove(_MyDSOFramer);

View File

@ -1529,7 +1529,7 @@ namespace Volian.Controls.Library
else if (_MyItemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true;
else if (_MyItemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true;
else if (_MyItemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true;
else if (_MyItemInfo.IsStepPart && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
else if (_MyItemInfo.IsStepPart && !_MyItemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
//else if (_MyItemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
else if (_MyItemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.Attach) > 0) replaceit = true;
@ -1720,8 +1720,11 @@ namespace Volian.Controls.Library
{
if (VerifyNoHardSpace(text, foundMatch, offset))
{
if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith("{\\par}"))
{
text = text.Substring(0, offset + foundMatch.MyMatch.Index) + foundMatch.MyWord.ReplaceWith + text.Substring(offset + foundMatch.MyMatch.Index + foundMatch.MyMatch.Length);
offset += foundMatch.MyWord.ReplaceWith.Length - foundMatch.MyMatch.Length;
}
}
}
}

View File

@ -944,7 +944,7 @@ namespace Volian.Print.Library
cb.SaveState();
cb.BeginLayer(layer);
SvgWatermark wm = new SvgWatermark(cb, watermark, System.Drawing.Color.Blue, .15F);
wm.SetSquareDotPattern(.7F);
//wm.SetSquareDotPattern(.7F);
//wm.SetTextPattern(8, 3);
//wm.SetTextPattern2(8);
//wm.SetHashPattern(1, 6);

View File

@ -916,7 +916,7 @@ namespace Volian.Svg.Library
{
DrawBackground(writer.DirectContentUnder);
DrawPageList(writer.DirectContent);
DrawWatermark(writer.DirectContentUnder);
DrawWatermark(writer.DirectContent);
if (DoZoomOMatic) DrawZoomOMatic(writer.DirectContent);
}
CurrentPageNumber++;
@ -927,7 +927,7 @@ namespace Volian.Svg.Library
{
DrawBackground(writer.DirectContentUnder);
DrawPageList(writer.DirectContent);
DrawWatermark(writer.DirectContentUnder);
DrawWatermark(writer.DirectContent);
if (DoZoomOMatic) DrawZoomOMatic(writer.DirectContent);
CurrentPageNumber++;
}
@ -1009,7 +1009,7 @@ namespace Volian.Svg.Library
cb.SaveState();
if (_WatermarkLayer != null) cb.BeginLayer(_WatermarkLayer);
SvgWatermark myWatermark = new SvgWatermark(cb, Watermark, System.Drawing.Color.Blue, .15F);
myWatermark.SetSquareDotPattern(.7F);
//myWatermark.SetSquareDotPattern(.7F);
myWatermark.Draw();
if (_WatermarkLayer != null) cb.EndLayer();
cb.RestoreState();
@ -1078,119 +1078,170 @@ namespace Volian.Svg.Library
{
_ContentByte = contentByte;
_Text = text;
float radius = .5F;
float space = 3;
//float radius = .5F;
//float space = 3;
_Color = new Color(color);
_Opacity = opacity;
SetDotPattern(radius, space);
SetTextLayout();
}
private void SetTextLayout()
{
Rectangle pageSize = _ContentByte.PdfWriter.PageSize; // Get page size
_Basefont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
float hgtA = _Basefont.GetAscentPoint(_Text, 12);
//float hgtD = basefont.GetDescentPoint(text,20);
float wid = _Basefont.GetWidthPointKerned(_Text, 12);
//Console.WriteLine("{0} {1} {2}",hgtA,hgtD,wid);
float rho = wid / hgtA;
float x2 = (rho * pageSize.Height - pageSize.Width) / (rho * rho - 1);
float y1 = x2 * rho;
float y2 = pageSize.Height - y1;
float x1 = pageSize.Width - x2;
_XOffset = x2 + x1 / 2;
_YOffset = y1 / 2;
_TextAngle = CalcAngle(y1, x1);
_Fontsize = (float)(10 * Math.Sqrt(x2 * x2 + y2 * y2) / hgtA);
}
public void SetDotPattern(float radius, float space)
{
_PatternPainter = _ContentByte.CreatePattern(radius * 2, radius * 2, radius * 2 + space, radius * 2 + space);
PdfGState gState = new PdfGState();
gState.FillOpacity = _Opacity;
_PatternPainter.SetGState(gState);
_PatternPainter.SetColorFill(_Color);
_PatternPainter.Circle(radius, radius, radius);
_PatternPainter.Fill();
}
public void SetSquareDotPattern(float radius)
{
_PatternPainter = _ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2);
PdfGState gState = new PdfGState();
gState.FillOpacity = .5f * _Opacity;
_PatternPainter.SetGState(gState);
_PatternPainter.SetColorFill(_Color);
_PatternPainter.Rectangle(0, 0, radius, radius);
_PatternPainter.Rectangle(radius * 2, radius, radius, radius);
_PatternPainter.Fill();
}
public void SetHashPattern(float thickness, float size)
{
_PatternPainter = _ContentByte.CreatePattern(size, size, size, size);
PdfGState gState = new PdfGState();
gState.FillOpacity = _Opacity;
gState.StrokeOpacity = _Opacity;
_PatternPainter.SetGState(gState);
_PatternPainter.SetLineWidth(.01F);
_PatternPainter.SetColorStroke(_Color); // Set color
_PatternPainter.MoveTo(0, 0);
_PatternPainter.LineTo(size, size);
_PatternPainter.MoveTo(size, 0);
_PatternPainter.LineTo(0, size);
_PatternPainter.Stroke();
}
public void SetTextPattern(float fontSize, float space)
{
float hgtA = _Basefont.GetAscentPoint(_Text, fontSize) + _Basefont.GetDescentPoint(_Text, fontSize);
float wid = _Basefont.GetWidthPointKerned(_Text, fontSize);
_PatternPainter = _ContentByte.CreatePattern(wid, hgtA, wid + space, hgtA + space);
_PatternPainter.SetFontAndSize(_Basefont, fontSize);
_PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100);
_PatternPainter.BeginText();
PdfGState gs1 = new PdfGState();
gs1.FillOpacity = _Opacity;
_PatternPainter.SetGState(gs1);
_PatternPainter.SetColorFill(_Color); // Set color
_PatternPainter.ShowText(_Text);
_PatternPainter.EndText();
}
public void SetTextPattern2(float fontSize)
{
BaseFont _Basefont2 = BaseFont.CreateFont(BaseFont.HELVETICA, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
float hgtA = _Basefont2.GetAscentPoint(_Text, fontSize);
float wid = _Basefont2.GetWidthPointKerned(_Text, fontSize);
_PatternPainter = _ContentByte.CreatePattern(wid * 2, hgtA * 2, wid * 2, hgtA * 2);
_PatternPainter.SetFontAndSize(_Basefont2, fontSize);
_PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100);
_PatternPainter.BeginText();
PdfGState gs1 = new PdfGState();
gs1.FillOpacity = _Opacity;
_PatternPainter.SetGState(gs1);
_PatternPainter.SetColorFill(_Color); // Set color
_PatternPainter.ShowText(_Text);
_PatternPainter.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _Text, wid, hgtA, 0);
_PatternPainter.EndText();
//SetDotPattern(radius, space);
//SetTextLayout();
}
//private void SetTextLayout()
//{
// Rectangle pageSize = _ContentByte.PdfWriter.PageSize; // Get page size
// _Basefont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
// float hgtA = _Basefont.GetAscentPoint(_Text, 12);
// //float hgtD = basefont.GetDescentPoint(text,20);
// float wid = _Basefont.GetWidthPointKerned(_Text, 12);
// //Console.WriteLine("{0} {1} {2}",hgtA,hgtD,wid);
// float rho = wid / hgtA;
// float x2 = (rho * pageSize.Height - pageSize.Width) / (rho * rho - 1);
// float y1 = x2 * rho;
// float y2 = pageSize.Height - y1;
// float x1 = pageSize.Width - x2;
// _XOffset = x2 + x1 / 2;
// _YOffset = y1 / 2;
// _TextAngle = CalcAngle(y1, x1);
// _Fontsize = (float)(10 * Math.Sqrt(x2 * x2 + y2 * y2) / hgtA);
//}
//public void SetDotPattern(float radius, float space)
//{
// _PatternPainter = _ContentByte.CreatePattern(radius * 2, radius * 2, radius * 2 + space, radius * 2 + space);
// PdfGState gState = new PdfGState();
// gState.FillOpacity = _Opacity;
// _PatternPainter.SetGState(gState);
// _PatternPainter.SetColorFill(_Color);
// _PatternPainter.Circle(radius, radius, radius);
// _PatternPainter.Fill();
//}
//public void SetSquareDotPattern(float radius)
//{
// _PatternPainter = _ContentByte.CreatePattern(radius * 4, radius * 2, radius * 4, radius * 2);
// PdfGState gState = new PdfGState();
// gState.FillOpacity = .5f * _Opacity;
// _PatternPainter.SetGState(gState);
// _PatternPainter.SetColorFill(_Color);
// _PatternPainter.Rectangle(0, 0, radius, radius);
// _PatternPainter.Rectangle(radius * 2, radius, radius, radius);
// _PatternPainter.Fill();
//}
//public void SetHashPattern(float thickness, float size)
//{
// _PatternPainter = _ContentByte.CreatePattern(size, size, size, size);
// PdfGState gState = new PdfGState();
// gState.FillOpacity = _Opacity;
// gState.StrokeOpacity = _Opacity;
// _PatternPainter.SetGState(gState);
// _PatternPainter.SetLineWidth(.01F);
// _PatternPainter.SetColorStroke(_Color); // Set color
// _PatternPainter.MoveTo(0, 0);
// _PatternPainter.LineTo(size, size);
// _PatternPainter.MoveTo(size, 0);
// _PatternPainter.LineTo(0, size);
// _PatternPainter.Stroke();
//}
//public void SetTextPattern(float fontSize, float space)
//{
// float hgtA = _Basefont.GetAscentPoint(_Text, fontSize) + _Basefont.GetDescentPoint(_Text, fontSize);
// float wid = _Basefont.GetWidthPointKerned(_Text, fontSize);
// _PatternPainter = _ContentByte.CreatePattern(wid, hgtA, wid + space, hgtA + space);
// _PatternPainter.SetFontAndSize(_Basefont, fontSize);
// _PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100);
// _PatternPainter.BeginText();
// PdfGState gs1 = new PdfGState();
// gs1.FillOpacity = _Opacity;
// _PatternPainter.SetGState(gs1);
// _PatternPainter.SetColorFill(_Color); // Set color
// _PatternPainter.ShowText(_Text);
// _PatternPainter.EndText();
//}
//public void SetTextPattern2(float fontSize)
//{
// BaseFont _Basefont2 = BaseFont.CreateFont(BaseFont.HELVETICA, Encoding.ASCII.EncodingName, BaseFont.EMBEDDED);
// float hgtA = _Basefont2.GetAscentPoint(_Text, fontSize);
// float wid = _Basefont2.GetWidthPointKerned(_Text, fontSize);
// _PatternPainter = _ContentByte.CreatePattern(wid * 2, hgtA * 2, wid * 2, hgtA * 2);
// _PatternPainter.SetFontAndSize(_Basefont2, fontSize);
// _PatternPainter.BoundingBox = new Rectangle(-20, -20, 100, 100);
// _PatternPainter.BeginText();
// PdfGState gs1 = new PdfGState();
// gs1.FillOpacity = _Opacity;
// _PatternPainter.SetGState(gs1);
// _PatternPainter.SetColorFill(_Color); // Set color
// _PatternPainter.ShowText(_Text);
// _PatternPainter.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _Text, wid, hgtA, 0);
// _PatternPainter.EndText();
//}
public void Draw()
{
_ContentByte.SaveState();
_ContentByte.BeginText();
_ContentByte.SetPatternFill(_PatternPainter);
_ContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE);
_ContentByte.SetLineWidth(.5F);
_ContentByte.SetFontAndSize(_Basefont, _Fontsize);// Set font and size
_ContentByte.SetColorStroke(_Color);
PdfGState gs2 = new PdfGState();
gs2.StrokeOpacity = _Opacity;
_ContentByte.SetGState(gs2);
_ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, _Text, _XOffset, _YOffset, _TextAngle);// Draw the text
_ContentByte.EndText();
_ContentByte.FillStroke(); // Controlled by TextRenderMode above
//_ContentByte.BeginText();
//_ContentByte.SetPatternFill(_PatternPainter);
//_ContentByte.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE);
//_ContentByte.SetLineWidth(.5F);
//_ContentByte.SetFontAndSize(_Basefont, _Fontsize);// Set font and size
//_ContentByte.SetColorStroke(_Color);
//PdfGState gs2 = new PdfGState();
//gs2.StrokeOpacity = _Opacity;
//_ContentByte.SetGState(gs2);
//_ContentByte.ShowTextAlignedKerned(PdfContentByte.ALIGN_CENTER, _Text, _XOffset, _YOffset, _TextAngle);// Draw the text
//_ContentByte.EndText();
_ContentByte.AddImage(WatermarkImage);
_ContentByte.RestoreState();
}
private float CalcAngle(float opposite, float adjacent)
//private float CalcAngle(float opposite, float adjacent)
//{
// return (float)(Math.Atan2(opposite, adjacent) * (180 / Math.PI));
//}
private Image _WatermarkImage;
public Image WatermarkImage
{
return (float)(Math.Atan2(opposite, adjacent) * (180 / Math.PI));
get
{
if (_WatermarkImage == null)
{
float fntSize = 200;
System.Drawing.Font fnt = new System.Drawing.Font("Arial", fntSize);
string msg = _Text;
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddString(msg, fnt.FontFamily, 0, fntSize, new System.Drawing.Point(0, 0),
System.Drawing.StringFormat.GenericTypographic);
System.Drawing.RectangleF bnds = gp.GetBounds();
gp.Reset();
int height = (int)bnds.Height;
int width = (int)bnds.Width;
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width + 2, height + 2);
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp))
{
g.FillRectangle(System.Drawing.Brushes.Transparent, 0, 0, width, height);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gp.AddString(msg, fnt.FontFamily, 0, fntSize, new System.Drawing.PointF(-bnds.X, -bnds.Y),
System.Drawing.StringFormat.GenericTypographic);
System.Drawing.Drawing2D.HatchBrush aHatchBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent25, System.Drawing.Color.FromArgb(64,
System.Drawing.Color.Blue), System.Drawing.Color.Transparent);
g.FillPath(aHatchBrush, gp);
g.DrawPath(new System.Drawing.Pen(System.Drawing.Color.FromArgb(96, System.Drawing.Color.Blue)), gp);
//g.DrawRectangle(System.Drawing.Pens.Cyan, 0, 0, bnds.Width, bnds.Height);
}
_WatermarkImage = iTextSharp.text.Image.GetInstance(bmp, System.Drawing.Imaging.ImageFormat.Png);
_WatermarkImage.SetAbsolutePosition(72, 72);
float H = _ContentByte.PdfWriter.PageSize.Height - 144;
float W = _ContentByte.PdfWriter.PageSize.Width - 144;
float ratio = bnds.Width / bnds.Height;
float W2 = (H - W / ratio) / (ratio - 1 / ratio);
float W1 = W - W2;
float H1 = (float)(Math.Sqrt(-4*(W1*W2)+H*H)+H)/2;
float H2 = H-H1;
float Theta = (float) Math.Atan(H1 / W1);
float h = H2 / (float) Math.Cos(Theta);
float w = H1 / (float) Math.Sin(Theta);
_WatermarkImage.Rotation = Theta; // 3.141592653F / 4;
_WatermarkImage.ScaleAbsolute(w, h);
}
return _WatermarkImage;
}
}
}