PPT文檔管理控件Aspose.Slides v19.5上線發佈!開始評估PDF轉換的時間花費!

Aspose.Slides for .NET一種獨特的表示處理API,使應用程序可以讀取,編寫,修改和轉換PowerPoint演示文稿。支持大多數Microsoft PowerPoint格式進行處理和操做。此外,API提供了許多高級功能,例如打印和渲染演示幻燈片到固定佈局格式,HTML和圖像。bash

Aspose.Slides for .NET更新至v19.5,開始評估PDF轉換的時間花費,新增支持將SVG圖像轉換爲形狀!ide

【下載Aspose.Words for .NET最新試用版】svg

具體更新內容

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更新說明】佈局

公共API更改

▲添加了IComment.ParentComment屬性

新的屬性ParentComment添加到IComment接口和Comment類中。它容許獲取或設置父註釋,從而以註釋和回覆的層次結構的形式建立對話框。ui

注意:若是設置ParentComment致使循環引用,則會拋出類型爲PptxEditException的異常。this

下面的代碼段顯示了添加一些註釋和一些回覆的示例:spa

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枚舉。rest

INormalViewPropertiescode

  • 屬性ShowOutlineIcons指定在正常視圖模式的任何內容區域中顯示大綱內容時應用程序是否應顯示圖標。
  • 屬性SnapVerticalSplitter指定當側面區域足夠小時,垂直分割器是否應捕捉到最小化狀態。
  • 屬性PreferSingleView指定用戶是否更喜歡在具備三個內容區域的標準普通視圖上看到全窗口單內容區域。若是啓用,則應用程序能夠選擇在整個窗口中顯示一個內容區域。
  • 屬性VerticalBarState和HorizontalBarState指定應顯示水平或垂直分割條的狀態。水平分割條將幻燈片與幻燈片下方的內容區域分開,垂直分割條將幻燈片與邊內容區域分開。
  • 屬性SnapVerticalSplitter指定當側面區域足夠小時,垂直分割器是否應捕捉到最小化狀態。
  • 屬性RestoredLeft和RestoredTop指定正常視圖的頂部或側面幻燈片區域的大小,當SplitterBarStateType.Restored值相應地應用於 VerticalBarState 和 HorizontalBarState*.*時

INormalViewRestoredPropertiesorm

  • 屬性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)已開通,各種資源及時分享,歡迎交流討論!

相關文章
相關標籤/搜索