没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:李显亮|2020-03-05 10:13:34.063|阅读 668 次
概述:Aspose.Words For .NET是一种高级Word文档处理API,用于执行各种文档管理和操作任务。接下来我们将进入关于“水印处理”的介绍,在Aspose.Words中学会如何处理Aspose.Words中的形状。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
Aspose.Words For .NET是一种高级Word文档处理API,用于执行各种文档管理和操作任务。API支持生成,修改,转换,呈现和打印文档,而无需在跨平台应用程序中直接使用Microsoft Word。此外,API支持所有流行的Word处理文件格式,并允许将Word文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。
本文讨论如何使用Aspose.Words以编程方式处理形状。Aspose.Words中的形状表示 绘图层中的对象,例如AutoShape,文本框,自由格式,OLE对象,ActiveX控件或图片。 Word文档可以包含一个或多个不同的形状。文档的形状由Shape类表示。
>>Aspose.Words for .NET已经更新至v20.3,新增4大新功能,包括Xamarin不再需要单独的DLL,FindReplaceOptions类扩展了新属性,实现了“ Letterlike”符号的正确呈现以及支持在文本框范围内动态拉伸图像,以及3钟增强型功能,点击下载体验
使用文档生成器插入形状
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); //Free-floating shape insertion. Shape shape = builder.InsertShape(ShapeType.TextBox, RelativeHorizontalPosition.Page, 100, RelativeVerticalPosition.Page, 100, 50, 50, WrapType.None); shape.Rotation = 30.0; builder.Writeln(); //Inline shape insertion. shape = builder.InsertShape(ShapeType.TextBox, 50, 50); shape.Rotation = 30.0; OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.Docx); // "Strict" or "Transitional" compliance allows to save shape as DML. so.Compliance = OoxmlCompliance.Iso29500_2008_Transitional; dataDir = dataDir + "Shape_InsertShapeUsingDocumentBuilder_out.docx"; // Save the document to disk. doc.Save(dataDir, so);
设置宽高比锁定
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); var shape = builder.InsertImage(dataDir + "Test.png"); shape.AspectRatioLocked = false; dataDir = dataDir + "Shape_AspectRatioLocked_out.doc"; // Save the document to disk. doc.Save(dataDir);
在单元格中设置形状布局
Document doc = new Document(dataDir + @"LayoutInCell.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Shape watermark = new Shape(doc, ShapeType.TextPlainText);
watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
watermark.IsLayoutInCell = true; // Display the shape outside of table cell if it will be placed into a cell.
watermark.Width = 300;
watermark.Height = 70;
watermark.HorizontalAlignment = HorizontalAlignment.Center;
watermark.VerticalAlignment = VerticalAlignment.Center;
watermark.Rotation = -40;
watermark.Fill.Color = Color.Gray;
watermark.StrokeColor = Color.Gray;
watermark.TextPath.Text = "watermarkText";
watermark.TextPath.FontFamily = "Arial";
watermark.Name = string.Format("WaterMark_{0}", Guid.NewGuid());
watermark.WrapType = WrapType.None;
Run run = doc.GetChildNodes(NodeType.Run, true)[doc.GetChildNodes(NodeType.Run, true).Count - 1] as Run;
builder.MoveTo(run);
builder.InsertNode(watermark);
doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2010);
dataDir = dataDir + "Shape_IsLayoutInCell_out.docx";
// Save the document to disk.
doc.Save(dataDir);
添加角落
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Shape shape = builder.InsertShape(ShapeType.TopCornersSnipped, 50, 50); OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.Docx); so.Compliance = OoxmlCompliance.Iso29500_2008_Transitional; dataDir = dataDir + "AddCornersSnipped_out.docx"; //Save the document to disk. doc.Save(dataDir, so);
获取实际形状边界点
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
var shape = builder.InsertImage(dataDir + "Test.png");
shape.AspectRatioLocked = false;
Console.Write("\nGets the actual bounds of the shape in points.");
Console.WriteLine(shape.GetShapeRenderer().BoundsInPoints);
指定垂直锚
Document doc = new Document(dataDir + @"VerticalAnchor.docx");
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
Shape textBoxShape = shapes[0] as Shape;
if (textBoxShape != null)
{
textBoxShape.TextBox.VerticalAnchor = TextBoxAnchor.Bottom;
}
doc.Save(dataDir + "VerticalAnchor_out.docx");
检测SmartArt形状
Document doc = new Document(dataDir + "input.docx");
int count = 0;
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
{
if (shape.HasSmartArt)
count++;
}
Console.WriteLine("The document has {0} shapes with SmartArt.", count);
水平尺格式
Aspose.Words API提供Shape.HorizontalRuleFormat属性,以访问水平规则形状的属性。HorizontalRuleFormat类公开了用于设置水平尺的基本属性,例如Height,Color,NoShade等。下面的代码示例演示如何设置HorizontalRuleFormat。
DocumentBuilder builder = new DocumentBuilder();
Shape shape = builder.InsertHorizontalRule();
HorizontalRuleFormat horizontalRuleFormat = shape.HorizontalRuleFormat;
horizontalRuleFormat.Alignment = HorizontalRuleAlignment.Center;
horizontalRuleFormat.WidthPercent = 70;
horizontalRuleFormat.Height = 3;
horizontalRuleFormat.Color = Color.Blue;
horizontalRuleFormat.NoShade = true;
builder.Document.Save("HorizontalRuleFormat.docx");
插入OLE对象作为图标
Aspose.Words API提供了Shape.InsertOleObjectAsIcon函数,以将嵌入式或链接的OLE对象作为图标插入文档。此功能允许指定图标文件和标题。OLE对象类型应使用文件扩展名进行检测。下面的代码示例演示如何将OLE对象作为Icon设置到文档中。
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.InsertOleObjectAsIcon(dataDir + "embedded.xlsx", false, dataDir + "icon.ico", "My embedded file");
doc.Save(dataDir + "EmbeddeWithIcon_out.docx");
Console.WriteLine("The document has been saved with OLE Object as an Icon.");
还想要更多吗?您可以点击阅读【2019 · Aspose最新资源整合】,查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(642018183),我们很高兴为您提供查询和咨询。 本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@fz165y.cn




在使用Parasoft C/C++test执行BugDetective数据流分析时,可能会遇到用户自定义的资源API,那在这种情况下,若要判断是否存在资源问题,如资源泄露等,则需要手动配置测试配置。
大型SaaS系统的自动化测试常常受制于界面变化快、结构复杂、加载机制多变等因素。从元素识别到脚本管理,SmartBear TestComplete帮助Salesforce建了可靠的自动化测试体系。
BarTender 标签管理系统,正是帮助企业轻松实现 GS1 标准化标签设计、编码生成与信息联动的强大工具。
Parasoft C/C++test 是一款功能强大的 C/C++ 软件测试工具,集成了静态代码分析、单元测试、集成测试和覆盖率分析等功能,单元测试作为其关键功能之一,为了适配多样化的目标部署环境,C/C++test 设计了灵活的测试结果收集机制。通过Socket通讯方式来收集单元测试结果,从而扩展其测试覆盖范围与应用场景。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@fz165y.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
星空最火知名网站