翻译|产品更新|编辑:李显亮|2019-06-20 11:33:59.170|阅读 197 次
概述:Aspose.Slides for .NET更新至v19.5,开始评估PDF转换的时间花费,新增支持将SVG图像转换为形状。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
Aspose.Slides for .NET一种独特的表示处理API,使应用程序能够读取,编写,修改和转换PowerPoint演示文稿。支持大多数Microsoft PowerPoint格式进行处理和操作。此外,API提供了许多高级功能,例如打印和渲染演示幻灯片到固定布局格式,HTML和图像。
Aspose.Slides for .NET更新至v19.5,开始评估PDF转换的时间花费,新增支持将SVG图像转换为形状!
【下载Aspose.Slides for .NET最新试用版】
key | 概述 | 类别 |
---|---|---|
SLIDESNET-41051 | PDF转换的时间花费评估 | 调查 |
SLIDESNET-41059 | Aspose.Slides for .NET:没有文本的形状的栅格化或矢量化 | 新功能 |
SLIDESNET-41015 | 通过API获取默认表格背景 | 新功能 |
SLIDESNET-40727 | 支持将SVG图像转换为形状 | 新功能 |
SLIDESNET-40856 | 支持Size表示气泡图的属性 | 新功能 |
SLIDESNET-40730 | 在Aspose.Slides中支持Office 365 | 新功能 |
SLIDESNET-40237 | 支持在生成的PPT中隐藏左侧幻灯片缩略图窗格 | 新功能 |
SLIDESNET-40870 | 支持Aspose.Slides中的评论回复 | 新功能 |
SLIDESNET-39057 | 支持设置图表外部数据源工作簿路径 | 新功能 |
SLIDESNET-40852 | 支持漏斗图和2D地图 | 新功能 |
SLIDESNET-41034 | 使用发言者备注进行渲染时,页码不正确 | Bug修复 |
SLIDESNET-41049 | OLE嵌入对象的图标在单击后更改 | Bug修复 |
更多更新细则请参考:【Aspose.Slides for .NET v19.5更新说明】
新的属性ParentComment添加到IComment接口和Comment类中。它允许获取或设置父注释,从而以注释和回复的层次结构的形式创建对话框。
注意:如果设置ParentComment导致循环引用,则会抛出类型为PptxEditException的异常。
下面的代码段显示了添加一些注释和一些回复的示例:
using (Presentation pres = new Presentation()) { // Add comment ICommentAuthor author1 = pres.CommentAuthors.AddAuthor("Author_1", "A.A."); IComment comment1 = author1.Comments.AddComment("comment1", pres.Slides[0], new PointF(10, 10), DateTime.Now); // Add reply for comment1 ICommentAuthor author2 = pres.CommentAuthors.AddAuthor("Autror_2", "B.B."); IComment reply1 = author2.Comments.AddComment("reply 1 for comment 1", pres.Slides[0], new PointF(10, 10), DateTime.Now); reply1.ParentComment = comment1; // Add reply for comment1 IComment reply2 = author2.Comments.AddComment("reply 2 for comment 1", pres.Slides[0], new PointF(10, 10), DateTime.Now); reply2.ParentComment = comment1; // Add reply to reply IComment subReply = author1.Comments.AddComment("subreply 3 for reply 2", pres.Slides[0], new PointF(10, 10), DateTime.Now); subReply.ParentComment = reply2; IComment comment2 = author2.Comments.AddComment("comment 2", pres.Slides[0], new PointF(10, 10), DateTime.Now); IComment comment3 = author2.Comments.AddComment("comment 3", pres.Slides[0], new PointF(10, 10), DateTime.Now); IComment reply3 = author1.Comments.AddComment("reply 4 for comment 3", pres.Slides[0], new PointF(10, 10), DateTime.Now); reply3.ParentComment = comment3; // Display hierarchy on console ISlide slide = pres.Slides[0]; var comments = slide.GetSlideComments(null); for (int i = 0; i < comments.Length; i++) { IComment comment = comments[i]; while (comment.ParentComment != null) { Console.Write("\t"); comment = comment.ParentComment; } Console.Write("{0} : {1}", comments[i].Author.Name, comments[i].Text); Console.WriteLine(); } // Remove comment1 and all its replies comment1.Remove(); }
普通视图由三个内容区域组成:幻灯片本身,侧面内容区域和底部内容区域。此信息允许应用程序将其视图状态保存到文件中,以便在重新打开时视图处于与上次保存演示文稿时相同的状态。添加了属性IViewProperties.NormalViewProperties以提供对演示文稿的普通视图属性的访问。添加了INormalViewProperties,INormalViewRestoredProperties 接口及其后代 SplitterBarStateType枚举。
INormalViewProperties
INormalViewRestoredProperties
using (Presentation pres = new Presentation()) { pres.ViewProperties.NormalViewProperties.HorizontalBarState = SplitterBarStateType.Restored; pres.ViewProperties.NormalViewProperties.VerticalBarState = SplitterBarStateType.Maximized; pres.ViewProperties.NormalViewProperties.RestoredTop.AutoAdjust = true; pres.ViewProperties.NormalViewProperties.RestoredTop.DimensionSize = 80; pres.ViewProperties.NormalViewProperties.ShowOutlineIcons = true; pres.Save("presentation.pptx", SaveFormat.Pptx); }
新属性SubstitutePictureTitle添加到IOleObjectFrame接口和OleObjectFrame类中。它允许获取,设置或更改OLE图标的标题:
////// Returns or set the title for OleObject icon. /// Read/write. ///////// When IsObjectIcon == false this value is ignored. /// The string can be truncated according to the size of the Ole icon. ///string SubstitutePictureTitle { get; set; }
下面的代码片段显示了创建Excel对象并设置其标题的示例:
string oleSourceFile = "ExcelObject.xlsx"; string oleIconFile = "Image.png"; using (Presentation pres = new Presentation()) { IPPImage image = null; ISlide slide = pres.Slides[0]; // Add Ole objects byte[] allbytes = File.ReadAllBytes(oleSourceFile); IOleObjectFrame oof = slide.Shapes.AddOleObjectFrame(20, 20, 50, 50, "Excel.Sheet.12", allbytes); oof.IsObjectIcon = true; // Add image object byte[] imgBuf = File.ReadAllBytes(oleIconFile); using (MemoryStream ms = new MemoryStream(imgBuf)) { image = pres.Images.AddImage(new Bitmap(ms)); } oof.SubstitutePictureFormat.Picture.Image = image; // Set caption to OLE icon oof.SubstitutePictureTitle = "Caption example"; }
BubbleSizeRepresentation指定气泡图表中气泡大小值的表示方式。可能的值有:BubbleSizeRepresentationType.Area和 BubbleSizeRepresentationType.Width。因此,添加了BubbleSizeRepresentationType枚举以指定将数据表示为气泡图大小的可能方式。
using (Presentation pres = new Presentation()) { IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Bubble, 50, 50, 600, 400, true); chart.ChartData.SeriesGroups[0].BubbleSizeRepresentation = BubbleSizeRepresentationType.Width; pres.Save("Presentation.pptx", SaveFormat.Pptx); }
添加了新的ISvgImage接口来表示SVG图像:
////// Represents an SVG image. ///[ComVisible(true), Guid("8BB43C22-78D1-4032-A149-82FCD3992F0F"), CsToCppPorter.CppVirtualInheritance("System.Object")] public interface ISvgImage { ////// Returns SVG content. /// Read-only. ///string SvgContent { get; } ////// Returns SVG data. /// Read-only. ///byte[] SvgData { get; } ////// Return callback interface used to resolve external resources during SVG documents import. /// Read-only. ///IExternalResourceResolver ExternalResourceResolver { get; } ////// Returns base URI of the specified SVG. Used to resolve relative links. /// Read-only. ///string BaseUri { get; } }
IImageCollection接口和ImageCollection类中添加了新的AddImage方法:
////// Add an image to a presentation from SVG object. //////Svg image object///Added image.///When svgImage parameter is null.IPPImage AddImage(ISvgImage svgImage);
这些方法提供了将Svg片段插入到演示文稿的图像集合的功能:
using (var p = new Presentation()) { string svgContent = File.ReadAllText(svgPath); ISvgImage svgImage = new SvgImage(svgContent); IPPImage ppImage = p.Images.AddImage(svgImage); p.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, ppImage.Width, ppImage.Height, ppImage); p.Save(outPptxPath, SaveFormat.Pptx); }
using (var p = new Presentation()) { string svgContent = File.ReadAllText(new Uri(new Uri(baseDir), "image1.svg").AbsolutePath); ISvgImage svgImage = new SvgImage(svgContent, new ExternalResourceResolver(), baseDir); IPPImage ppImage = p.Images.AddImage(svgImage); p.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, ppImage.Width, ppImage.Height, ppImage); p.Save(outPptxPath, SaveFormat.Pptx); }
新属性SvgImage已经添加到IPPImage接口和PPImage类:
////// Returns or sets ISvgImage object//////This value indicates that this image has been created from svg.ISvgImage SvgImage { get; set; }
IShapeCollection接口和ShapeCollection类中添加了新的AddGroupShape方法:
////// Creates a new GroupShape, fills it with converted shapes from SVG and adds it to the end of the collection. //////Svg image object///The X coordinate for the left side of the shape group frame. ///The Y coordinate for the top side of the shape group frame.///The width of the group of the shape group frame. ///The height of a group of the shape group frame. ///Created GroupShape object. IGroupShape AddGroupShape(ISvgImage svgImage, float x, float y, float width, float height);
此方法允许将表示SVG数据的SvgImage对象转换为形状组:
using (Presentation pres = new Presentation(pptxFileName)) { PictureFrame pFrame = pres.Slides[0].Shapes[0] as PictureFrame; ISvgImage svgImage = pFrame.PictureFormat.Picture.Image.SvgImage; if (svgImage != null) { // Convert svg image into group of shapes IGroupShape groupShape = pres.Slides[0].Shapes.AddGroupShape(svgImage, pFrame.Frame.X, pFrame.Frame.Y, pFrame.Frame.Width, pFrame.Frame.Height); // remove source svg image from presentation pres.Slides[0].Shapes.Remove(pFrame); } }
ASPOSE技术交流QQ群(642018183)已开通,各类资源及时分享,欢迎交流讨论!
慧都20万+用户答谢惠,ASPOSE系列产品火热促销中,最高直降8万元!>>立即领取优惠
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn