Aspose.Pdf for .NET如何使用渐变色填充PDF文件里的图形对象

作者:控件中国网   出处:控件中国网   2016-09-30 09:56:31   阅读:5

Aspose.Pdf for .NET是一款专门用于处理PDF文档的控件,不仅可以创建、编辑和保存PDF文档,还可以对PDF文档进行各种复杂的操作、分割、合并、插入页眉页脚、添加水印、转换为其它文档格式等,在新发布了12.0后开发人员可以利用API对PDF文档内的图形对象进行渐变色的填充,具体可以参考下面的C#代码:
// Create Document instance
Document doc = new Document();
// Add page to pages collection of PDF file
Aspose.Pdf.Page page = doc.Pages.Add();
// Create Graph instance
Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(300, 300);
// Add graph object to paragraphs collection of page instance
page.Paragraphs.Add(graph);
// Create Rectangle instance
Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(0, 0, 300, 300);
// Add rectangle object to shapes collection of Graph object
graph.Shapes.Add(rect);
// Specify Gradient fill color for Graph object
rect.GraphInfo.FillColor = new Aspose.Pdf.Color
{
PatternColorSpace = new Aspose.Pdf.Drawing.GradientAxialShading(Aspose.Pdf.Color.Red, Aspose.Pdf.Color.Blue) { Start = new Aspose.Pdf.Point(0, 0), End = new Aspose.Pdf.Point(300, 300) }
};
// Save PDF file
doc.Save("GradiantFill.PDF");
Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat