编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

PPT文档管理控件Aspose.Slides v19.5上线发布!| 附下载

wxchong 2024-10-21 12:51:53 开源技术 46 ℃ 0 评论

Aspose.Slides for .NET一种独特的表示处理API,使应用程序能够读取,编写,修改和转换PowerPoint演示文稿。支持大多数Microsoft PowerPoint格式进行处理和操作。此外,API提供了许多高级功能,例如打印和渲染演示幻灯片到固定布局格式,HTML和图像。

Aspose.Slides for .NET更新至v19.5,开始评估PDF转换的时间花费,新增支持将SVG图像转换为形状!

SLIDESNET-41051PDF 转换的时间花费评估 调查

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-41049OLE嵌入对象的图标在单击后更改 Bug修复

更多更新细则和下载试用请点击文末“了解更多”查看详情。

公共API更改


▲添加了IComment.ParentComment属性

新的属性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,INormalViewRestoredProperties和相关成员,以提供对演示文稿的“常规视图属性”的访问。

普通视图由三个内容区域组成:幻灯片本身,侧面内容区域和底部内容区域。此信息允许应用程序将其视图状态保存到文件中,以便在重新打开时视图处于与上次保存演示文稿时相同的状态。添加了属性IViewProperties.NormalViewProperties以提供对演示文稿的普通视图属性的访问。添加了INormalViewPropertiesINormalViewRestoredProperties 接口及其后代 SplitterBarStateType枚举。

INormalViewProperties

  • 属性ShowOutlineIcons指定在正常视图模式的任何内容区域中显示大纲内容时应用程序是否应显示图标。
  • 属性SnapVerticalSplitter指定当侧面区域足够小时,垂直分割器是否应捕捉到最小化状态。
  • 属性PreferSingleView指定用户是否更喜欢在具有三个内容区域的标准普通视图上看到全窗口单内容区域。如果启用,则应用程序可以选择在整个窗口中显示一个内容区域。
  • 属性VerticalBarState和HorizontalBarState指定应显示水平或垂直分割条的状态。水平分割条将幻灯片与幻灯片下方的内容区域分开,垂直分割条将幻灯片与边内容区域分开。
  • 属性SnapVerticalSplitter指定当侧面区域足够小时,垂直分割器是否应捕捉到最小化状态。
  • 属性RestoredLeft和RestoredTop指定正常视图的顶部或侧面幻灯片区域的大小,当SplitterBarStateType.Restored值相应地应用于 VerticalBarState 和 HorizontalBarState*.*时

INormalViewRestoredProperties

  • 属性DimensionSize 指定幻灯片区域的大小(restoredTop的子节点的宽度,restoredLeft的子节点的高度)。
  • 属性AutoAdjust指定在调整应用程序中包含视图的窗口大小时,旁边内容区域的大小是否应该补偿新大小。
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);
}

▲添加了新的IOleObjectFrame .SubstitutePictureTitle属性

新属性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接口和SvgImage类

添加了新的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; }
}

▲AddImage方法已添加到IImageCollection接口和ImageCollection类中

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类

新属性SvgImage已经添加到IPPImage接口和PPImage类:

////// Returns or sets ISvgImage object//////This value indicates that this image has been created from svg.ISvgImage SvgImage { get; set; }

▲AddGroupShape方法添加到IShapeCollection接口和IShapeCollection类中

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)已开通,各类资源及时分享,欢迎交流讨论!

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表