如何使用C#桌面应用程序插入Ppt文件的字体大小和字体名称以及其他属性 [英] How Do I Cange The Font Size And Font Name And Other Properties Of Ppt File Using C # Desktop Application
本文介绍了如何使用C#桌面应用程序插入Ppt文件的字体大小和字体名称以及其他属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码提取文件和字体大小以及ppt文件的名称。
现在我想以编程方式更改这些属性
this code extract the text and font size and name of ppt file .
now i want to change these properties pro-grammatically
string path = @"c:\users\taimoor\PPT\";
Microsoft.Office.Interop.PowerPoint.Application powerPointApp =
new Microsoft.Office.Interop.PowerPoint.Application();
PowerPoint.Presentations multiPresentations = powerPointApp.Presentations;
Microsoft.Office.Interop.PowerPoint.Presentation presentation = multiPresentations.Open(path + "Demo.pptx");
string presentationText = "";
string fonts = "";
for (int i = 0; i < presentation.Slides.Count; i++)
{
foreach (object item in presentation.Slides[i + 1].Shapes)
{
PowerPoint.Shape shape = (PowerPoint.Shape) item;
var slide = (PowerPoint.Slide) item;
foreach (var it in slide.Shapes)
{
if (shape.HasTextFrame == MsoTriState.msoTrue)
{
string c= shape.TextFrame.TextRange.Font.Size.ToString(CultureInfo.InvariantCulture);
textBox3.Text = c;
if (shape.TextFrame.HasText == MsoTriState.msoTrue)
{
PowerPoint.TextRange textRange = shape.TextFrame.TextRange;
string text = textRange.Text;
string font = Font.Name;
float size = Font.Size;
FontStyle style = Font.Style;
presentationText += text + " ";
// get the text size head and body
float fontSize = shape.TextFrame.TextRange.Font.Size;
// get the length of body text
int bodyLength = shape.TextFrame.TextRange.Length;
// get text of all body
string v = shape.TextFrame.TextRange.Text;
推荐答案
这篇关于如何使用C#桌面应用程序插入Ppt文件的字体大小和字体名称以及其他属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文