简体   繁体   中英

How to set image position and image size in PPT in C# (Aspose)?

I want to move image position and want to set image size in PPT in C# which uses Aspose.slides. How can I resolve this issue?

i am going to cite the doc

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();

// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
    System.IO.Directory.CreateDirectory(dataDir);

// Instantiate Presentation class that represents the PPTX
using (Presentation pres = new Presentation())
{

    // Get the first slide
    ISlide sld = pres.Slides[0];

    // Instantiate the ImageEx class
    System.Drawing.Image img = (System.Drawing.Image)new Bitmap(dataDir+ "aspose-logo.jpg");
    IPPImage imgx = pres.Images.AddImage(img);

    // Add Picture Frame with height and width equivalent of Picture
    IPictureFrame pf = sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);

    // Apply some formatting to PictureFrameEx
    pf.LineFormat.FillFormat.FillType = FillType.Solid;
    pf.LineFormat.FillFormat.SolidFillColor.Color = Color.Blue;
    pf.LineFormat.Width = 20;
    pf.Rotation = 45;

    //Write the PPTX file to disk
    pres.Save(dataDir + "RectPicFrameFormat_out.pptx", SaveFormat.Pptx);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM