问题描述:Spread 可以打印到PDF文件,但是无法打印Spread 背景图到PDF,如何打印背景图片?
问题解答:可以通过Spread PrintBackground 事件来手动绘制背景图到 PDF 文件。
关键代码:
- private void fpSpread1_PrintBackground(object sender, FarPoint.Win.Spread.PrintBackgroundEventArgs e)
- {
- System.Drawing.Drawing2D.GraphicsState saveState = e.Graphics.Save();
- Rectangle rect = e.SheetRectangle;
- rect.Width = (int)AdjustWorkaroundForPDFPrint((float)rect.Width);
- rect.Height = (int)AdjustWorkaroundForPDFPrint((float)rect.Height);
- e.Graphics.SetClip(rect);
- e.Graphics.SetClip(rect);
- e.Graphics.DrawImage(fpSpread1.BackgroundImage, rect);
- e.Graphics.Restore(saveState);
- }
复制代码
效果截图:
打印之前截图:
打印之后截图:
示例下载:点击下载 |