PPT document management controls Aspose.Slides v19.5 release on-line! Began evaluating PDF conversion time is spent!

Aspose.Slides for .NET represents a unique processing API, enables applications to read, write, modify and convert PowerPoint presentations. It supports most Microsoft PowerPoint format for processing and operations. In addition, API offers many advanced features, such as printing and presentation slides to render fixed layout format, HTML and images.

Aspose.Slides for .NET update to v19.5, began evaluating PDF conversion time spent, added support for the SVG image is converted into shape!

[Download the latest trial version of Aspose.Words for .NET]

Specific updates

key Outline category
SLIDESNET-41051 PDF conversion takes time to assess survey
SLIDESNET-41059 Aspose.Slides for .NET: rasterized shape or no text vectorization new function
SLIDESNET-41015 Get the default table background by API new function
SLIDESNET-40727 It supports the SVG image into shape new function
SLIDESNET-40856 Bubble Size attribute indicates support of FIG. new function
SLIDESNET-40730 Support Office 365 in the Aspose.Slides new function
SLIDESNET-40237 Support hidden in the left pane of slide thumbnails generated PPT new function
SLIDESNET-40870 Aspose.Slides reply comments in support of new function
SLIDESNET-39057 Chart support setting an external data source workbook path new function
SLIDESNET-40852 Support funnel plot and 2D map new function
SLIDESNET-41034 When using speaker notes for rendering, page number is incorrect Bug fixes
SLIDESNET-41049 OLE embedded object icons change after clicking Bug fixes

For more details, please refer to the update: [Aspose.Slides for .NET v19.5 update description]

Public API changes

▲ added IComment.ParentComment property

New property ParentComment added to IComment Comment classes and interfaces. It allows Gets or sets the parent annotation to create dialog boxes in the form of comments and replies hierarchy.

Note: If you set ParentComment cause a circular reference, is thrown PptxEditException type of exception.

The following code fragment shows an example add comments, and some responses:

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();
}

▲ add IViewProperties.NormalViewProperties, INormalViewRestoredProperties and related members, to provide access to the "General View Properties" presentation of.

SUMMARY normal view of three areas: the slide itself, the content side and a bottom area of the content area. This information allows the application to save it to a file view state, so that the view is the same as when last saved presentation state when reopened. Add a property IViewProperties.NormalViewProperties to provide access to the general view of the presentation attributes. Added INormalViewProperties , INormalViewRestoredProperties interface and its descendants SplitterBarStateType enumeration.

INormalViewProperties

  • ShowOutlineIcons property specifies the content displayed in any area of ​​the normal view mode whether the application should display an icon when the syllabus.
  • SnapVerticalSplitter attribute specifies when the side region is sufficiently small, if vertical segmentation should capture the minimized state.
  • PreferSingleView attribute specifies whether the user prefers to see the full contents of a single window region on a standard three general view of a content area. If enabled, the application can choose to display a content area in the whole window.
  • 属性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)已开通,各类资源及时分享,欢迎交流讨论!


转载于:https://juejin.im/post/5d0b3bc6e51d4510774a887b

Guess you like

Origin blog.csdn.net/weixin_33819479/article/details/93183555