Metni Dinamik Olarak Ekleme
Contents
[
Hide
]
Her iki yöntem de şu adımları izler:
- Bir sunum oluşturun.
- Boş bir slayt ekleyin.
- Bir metin kutusu ekleyin.
- Metin ayarlayın.
- Sunumu yazın.
VSTO
private void AddTextBox()
{
//Bir sunum oluştur
PowerPoint.Presentation pres = Globals.ThisAddIn.Application
.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);
//Boş slayt düzenini al
PowerPoint.CustomLayout layout = pres.SlideMaster.
CustomLayouts[7];
//Boş bir slayt ekle
PowerPoint.Slide sld = pres.Slides.AddSlide(1, layout);
//Metin ekle
PowerPoint.Shape shp =sld.Shapes.AddTextbox
(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal,150, 100, 400, 100);
//Metni ayarla
PowerPoint.TextRange txtRange = shp.TextFrame.TextRange;
txtRange.Text = "Text added dynamically";
txtRange.Font.Name = "Arial";
txtRange.Font.Bold = Microsoft.Office.Core.MsoTriState.msoTrue;
txtRange.Font.Size = 32;
//Çıktıyı diske kaydet
pres.SaveAs("outVSTOAddingText.ppt",
PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,
Microsoft.Office.Core.MsoTriState.msoFalse);
}
Aspose.Slides
static void AddTextBox()
{
//Bir sunum oluştur
Presentation pres = new Presentation();
//Boş slayt varsayılan olarak eklenir, oluşturduğunuzda
//varsayılan yapıcıdan sunum oluştururken
//Bu nedenle, hiçbir boş slayt eklememize gerek yok
Slide sld = pres.GetSlideByPosition(1);
//Arial için font indeksini al
//Sunumu varsayılan yapıcıdan oluşturursanız daima 0'dır
//varsayılan yapıcı
int arialFontIndex = 0;
//Bir metin kutusu ekle
//Bunu eklemek için önce bir dikdörtgen ekleyeceğiz
Shape shp = sld.Shapes.AddRectangle(1200, 800, 3200, 370);
//Çizgisini gizle
shp.LineFormat.ShowLines = false;
//Sonra içinde bir metin çerçevesi ekle
TextFrame tf = shp.AddTextFrame("");
//Metni ayarla
tf.Text = "Text added dynamically";
Portion port = tf.Paragraphs[0].Portions[0];
port.FontIndex = arialFontIndex;
port.FontBold = true;
port.FontHeight = 32;
//Çıktıyı diske kaydet
pres.Write("outAspose.ppt");
}