إضافة إطار صورة إلى العرض التقديمي

VSTO

فيما يلي الكود لإضافة صورة في عرض تقديمي باستخدام VSTO:


  string ImageFilePath="AddPicture.jpg";

 Slide slide = Application.ActivePresentation.Slides[1];

 slide.Shapes.AddPicture(ImageFilePath, Microsoft.Office.Core.MsoTriState.msoFalse,

 Microsoft.Office.Core.MsoTriState.msoCTrue, 0, 0);

Aspose.Slides

لإضافة إطار صورة بسيط إلى الشريحة الخاصة بك، يرجى اتباع الخطوات أدناه:

  1. إنشاء مثيل لفئة Presentation.
  2. الحصول على مرجع الشريحة باستخدام فهرستها.
  3. إنشاء كائن Image عن طريق إضافة صورة إلى مجموعة Images المرتبطة بكائن Presentation الذي سيُستخدم لملء الشكل.
  4. حساب عرض وارتفاع الصورة.
  5. إنشاء PictureFrame وفقًا للعرض والارتفاع باستخدام الطريقة AddPictureFrame التي يوفرها كائن Shapes المرتبط بالشريحة المرجعية.
  6. إضافة إطار صورة (يحتوي على الصورة) إلى الشريحة.
  7. كتابة العرض التقديمي المعدل كملف PPTX.

يتم تنفيذ الخطوات السابقة في المثال المعطى أدناه.


   string ImageFilePath = "AddPicture.jpg";

  //Instantiate Prseetation class that represents the PPTX

  Presentation pres = new Presentation();

  //Get the first slide

  ISlide sld = pres.Slides[0];

  //Instantiate the ImageEx class

  using IImage img = Images.FromFile(ImageFilePath);

  IPPImage imgx = pres.Images.AddImage(img);

  //Add Picture Frame with height and width equivalent of Picture

  sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);

Download Running Code

Download Sample Code