110,535
社区成员
发帖
与我相关
我的任务
分享
float y = 10;
float x = 160;
PdfDocument document = new PdfDocument();
document.LoadFromFile(filePath);
PdfFont font = new PdfFont(PdfFontFamily.TimesRoman, 30f, PdfFontStyle.Italic | PdfFontStyle.Bold);
PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Center);
PdfPageLayer layer;
try
{
for (int i = 0; i < document.Pages.Count; i++)
{
document.Pages[i].PageLayers.DeleteOldLayer("WaterMark");
try
{
layer = document.Pages[i].PageLayers.Add("WaterMark", true);
}
catch (NullReferenceException )
{
throw;
}
layer.Graphics.SetTransparency(0.3f);
layer.Graphics.DrawString(mark, font, PdfBrushes.Red, x, y, format);
}
}
catch (Exception ex)
{
}
try
{
throw new NullReferenceException();
}
catch (NullReferenceException e)
{
Console.WriteLine(e);
throw;
}
我们想说的是,调试是调试,vs断在那里是给你提示,你继续运行就会捕获。结论:不是没有捕获,只是IDE调试中断在那里