1金币
使用下列代码添加水印,不冻结列则显示3列水印,冻结10列则水印直接飞到右侧了,就显示一半,为什么,怎样解决?
private static void fpSpread_PrintBackground(object sender, FarPoint.Win.Spread.PrintBackgroundEventArgs e)
{
try
{
var text = $"2023 1111 为什么";
var imgSize = e.SheetRectangle.Width / 3;
var fontSize = 14;
var font = new System.Drawing.Font("宋体", fontSize, System.Drawing.FontStyle.Bold);
using (var img = new System.Drawing.Bitmap(imgSize, imgSize))
{
using (var g = System.Drawing.Graphics.FromImage(img))
{
g.Clear(System.Drawing.Color.White);
//将原点移动 到图片中点
g.TranslateTransform(fontSize, imgSize / 2);
//以原点为中心 转 -45度
g.RotateTransform(-45);
g.DrawString(text, font, System.Drawing.Brushes.LightGray, 0, 0);
g.Save();
}
var pic = new FarPoint.Win.Picture(img, FarPoint.Win.RenderStyle.Tile);
pic.AlignHorz = FarPoint.Win.HorizontalAlignment.Distributed;
pic.AlignVert = FarPoint.Win.VerticalAlignment.Distributed;
pic.Paint(e.Graphics, e.SheetRectangle);
}
}
catch (Exception ex)
{
}
}
|
|