Spread打印设置页眉页脚-插入图片

发布时间:2013/12/17 00:12 发布者:roger.wang

返回博客中心

我们基于《Spread自定义打印页眉或页脚》这篇文章,来实现在页眉、页脚插入图片。

首先,我们通过一张图来直观的了解Spread的页面布局。

printmargins

 

Spread的打印和打印预览,用PrintInfo类来实现。 故为了在页眉、页脚插入图片,我们先看看按照Spread产品自带的接口文档:Spread Windows Forms 7.0 Product Documentation ---Customizing the Printed Page Header or Footer [菜单路径: 开始-->所有程序-->ComponentOne—>Spread Studio for .net 7.2—>Spread Winforms-->Spread Help (CHM)]

我们找到图片对应的属性:public Image[] Images {get; set;}

 
  1: // Define the printer settings
  2: FarPoint.Win.Spread.PrintInfo printset = new FarPoint.Win.Spread.PrintInfo(); 
  3: printset.Colors = new Color[] {Color.Red, Color.Blue}; 
  4: printset.Header = "Print Job For /nFPT Inc."; 
  5: printset.Footer = "This is Page /p/nof /pc Pages"; 
  6: printset.Images = new Image[] {Image.FromFile("D:\Corporate.jpg"), Image.FromFile("D:\Building.jpg")}; 
  7: printset.RepeatColStart = 1; 
  8: printset.RepeatColEnd = 25; 
  9: printset.RepeatRowStart = 1; 
 10: printset.RepeatRowEnd = 25; 
 11: 
 12: // Assign the printer settings to the sheet and print it
 13: fpSpread1.Sheets[0].PrintInfo = printset; 
 14: fpSpread1.PrintSheet(0);
 15: 

 

其次,我们又跳转到《Customizing the Printed Page Header or Footer 》帮助文档中,这个文档,清晰的定义了Footer、Header的高级用法。(PrintInfo类的Footer, Header属性,是string类型,非常方便使用和扩展)

spread_custom_head_footer

 

最后,我们照葫芦画瓢开始编码。 下面的demo源码实现的页眉、页脚插入图片, 截图如下:

Spread_PrintPreview

 

源码下载:


关于葡萄城

赋能开发者!葡萄城是专业的集开发工具、商业智能解决方案、低代码开发平台于一身的软件和服务提供商,为超过 75% 的全球财富 500 强企业提供服务。葡萄城专注控件软件领域30年,希望通过模块化的开发控件、灵活的低代码应用开发平台等一系列开发工具、解决方案和服务,帮助开发者快速响应复杂多变的业务需求,最大程度地发挥开发者的才智和潜能,让开发者的 IT 人生更从容更美好。

了解详情,请访问葡萄城官网