Free Support Forum - aspose.com

Manipulate images using ASPOSE Slides


#1

I have to create a report and print it in word and excel with the following requirement:

1: The first page has some hi-res images e.g. some different geometric shapes with text in it. The location of the image(16 images in total ) on the page will be static, however the fill color of image can be either green or grey.E.g. one box can be green for one user , for other it can be grey etc.

2: the second page of the report will be data from a DB and will formatted as a content tree structure.

I am planning to use ASPOSE for this.

I am planning to create a template with superimposed images, e.g. green filled image and grey filled image superimposed on each other .Depending on the selection made by the user at runtime, I want to "Send to Back" or "Bring to Front." Can I change the "Send to Back" or "Bring to Front" properties at runtime depending on parameters passed to the report?

Also, I need to make sure that the template approach will not lead to issues when multiple user try to generate the report.

Also, I want the image path to be configurable, so that when business wants to change the text or color of the image, I do not need to redeploy the code. I can just change the image.


#2

Hi Rachana,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I am not very clear about your requirement. Are you interested in generating Word and Excel files with images? Or you are looking for a feature to convert PPT file to Word and Excel format? Please share some more details and some sample of your requirements with us so we can assist you in a better way.

Thanks & Regards,


#3

Please see the updated question below. Will appreciate a response asap.

I have to create a report and print it in PPT with the following requirement:

1: The first page has some hi-res images e.g. some different geometric shapes with text in it. The location of the image(16 images in total ) on the page will be static, however the fill color of image can be either green or grey.E.g. one box can be green for one user , for other it can be grey etc.

2: the second page of the report will be data from a DB and will formatted as a content tree structure.

I am planning to use ASPOSE for this.

I am planning to create a template with the images or shapes, pre existing , with superimposed images, e.g. green filled image and grey filled image superimposed on each other .Depending on the selection made by the user at runtime, I want to “Send to Back” or “Bring to Front.” Can I change the “Send to Back” or “Bring to Front” properties at runtime depending on parameters passed to the report?

Also, I need to make sure that the template approach will not lead to issues when multiple user try to generate the report.

Also, I want the image path to be configurable, so that when business wants to change the text or color of the image, I do not need to redeploy the code. I can just change the image.



#4

Hi Rachana,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks you for the details.

rachanadikshit@hotmail.com:
Please see the updated question below. Will appreciate a response asap.

1: The first page has some hi-res images e.g. some different geometric shapes with text in it. The location of the image(16 images in total ) on the page will be static, however the fill color of image can be either green or grey.E.g. one box can be green for one user , for other it can be grey etc.

Please see the following documentation link with details regarding how to work with shapes and pictures using Aspose.Slides for .NET.

http://www.aspose.com/docs/display/slidesnet/Working+with+Shapes

rachanadikshit@hotmail.com:

2: the second page of the report will be data from a DB and will formatted as a content tree structure.

I am not sure regarding your above requirement. Please share some sample presentation file (creating manually) to show the required feature.

rachanadikshit@hotmail.com:

I am planning to create a template with the images or shapes, pre existing , with superimposed images, e.g. green filled image and grey filled image superimposed on each other .Depending on the selection made by the user at runtime, I want to "Send to Back" or "Bring to Front." Can I change the "Send to Back" or "Bring to Front" properties at runtime depending on parameters passed to the report?

The IShapeCollection class exposes Reorder() method to set the order of shapes in a slide. Please see the following sample code for your reference:

//Instantiate Prseetation class that represents the PPTX

using (Presentation pres = new Presentation())

{

//Get the first slide

ISlide sld = pres.Slides[0];

//Add autoshapes of rectangle type

IAutoShape shp = sld.Shapes.AddAutoShape(Aspose.Slides.ShapeType.Rectangle, 50, 150, 150, 50);

IAutoShape shp2 = sld.Shapes.AddAutoShape(Aspose.Slides.ShapeType.Rectangle, 70, 170, 170, 70);

//Get all shapes in a slide

IShapeCollection collection = sld.Shapes;

//Set order -- in the below case Shape2 will be on top of shape one

//Change the first parameter "index" to 0 and Shape2 will be at bottom.

collection.Reorder(1, shp2);

//Write the PPTX file to disk

pres.Write("c:\\data\\RectShp1.pptx");

}

rachanadikshit@hotmail.com:

Also, I need to make sure that the template approach will not lead to issues when multiple user try to generate the report.

Well, it depends on how you are handling the user’s interaction in your application. In case you have any specific concern regarding this, please share and we will be happy to assist you accordingly.

rachanadikshit@hotmail.com:

Also, I want the image path to be configurable, so that when business wants to change the text or color of the image, I do not need to redeploy the code. I can just change the image.

Well, I am afraid, this is not possible as Pictures / images are embedded in the presentation file and are not linked with the source. However, in your application you can implement the logic to update an image in your presentation file. Please see the following sample code for reference.

//Accessing the presentation

Presentation pres = new Presentation(path + "RectShpPic.pptx");

ISlide sl;

for (int i = 0; i < pres.Slides.Count; i++)

{

sl = pres.Slides[i];

for (int j = 0; j < sl.Shapes.Count; j++)

{

// Accessing the shape with picture

Aspose.Slides.IShape sh = sl.Shapes[j];

//Getting the fill type of the shape

FillType fillType = sh.FillFormat.FillType;

//If the fill type of shape is picture

if (fillType == FillType.Picture)

{

//Set the picture

System.Drawing.Image img = (System.Drawing.Image)new Bitmap(path + "logo.jpg");

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

sh.FillFormat.PictureFillFormat.Picture.Image = imgx;

}

}

}

pres.Write(path + "ChangedPic.ppt");

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,


#5

Thank you for your response. I am also considering another approach. Instead of a static image, I am planning to use ASPOSE for generating PPT from templates . The template will have custom geometric shapes (16 custom shapes arranged at specific positions on the page). Each shape will have text that will be filled with data from DB.The background color of the shapes can be controlled at runtime too. The position of the shapes is really important as it should look just the way my web UI looks.


Q: I wanted to make sure that there will be no performance issue if i use this approach and multiple users are trying to print simultaneously using the same template. Please confirm.

Also, I have to generate the same report , with same data format and text etc in PPT too.
Q: Please confirm the performance issue for those two as well.
Q: Do I need to create the template for both word and PPT , or is there a better approach , i.e. convert the word page to image and place it on PPT?
Q: Will I need aspose excel and aspose PPT for this purpose?

note: The shapes will not necessarily be standard shapes like rectangles etc, it ca be a complicated shape.

#6

Hi Rachana,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please see the following thread which contains the reply to all your queries related to different products.

http://www.aspose.com/community/forums/thread/527166/known-performance-issues.aspx

Thanks & Regards,


#7

Ok. ALso the shapes that I need on my template will not be the standard shapes like rectangle etc.

If I create these shapes on my word template, can aspose recognize these shapes at runtime? Is there a content control kind of concept that I can use here?

ALso, coming back to the performance issues using template.Please respond to the question

#8

Hi
Rachana,<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

<o:p> </o:p>

bluefalcon.7691:
Ok. ALso the shapes that I need on my template
will not be the standard shapes like rectangle etc.<o:p></o:p>

If I create these shapes on my word
template, can aspose recognize these shapes at runtime? Is there a content
control kind of concept that I can use here?<o:p></o:p>

<o:p></o:p>

<o:p> </o:p>

Well, I am afraid Aspose.Words and
Aspose.Slides have different object models and object (shapes) from one API
cannot be recognized by other API at runtime. You will need to convert such
shapes to images and add them to presentation.<o:p></o:p>

<o:p> </o:p>

bluefalcon.7691:
<o:p></o:p>

ALso, coming back to the performance
issues using template. Please respond to the question<o:p></o:p>

<o:p></o:p>

<o:p> </o:p>

Performance
is totally dependent on you implementation. If you are using a multi-threaded
application and different (copies) of the same template are used, I think there
won’t be much performance implications in that case. However, again, it depends
on your implementation and the contents of your reports. <o:p></o:p>

<o:p> </o:p>

Thanks
& Regards,<o:p></o:p>


#9

How can i manipulate text on top of image please.
Thank you


#10

@annadatha.rao,

Can you please share the desired output that you want to generate using Aspose.Slides and I will try to help you further in this regard.


#11

question 1.png (47.6 KB)

Please see the file attached.

Image and text shown (blue one is image ), ‘ppt output’ is text.

Thank you,
Annadatha.


#12

I am really sorry , if it is late night for you , please reply in morning.

Thank you,
Annadatha.


#13

@annadatha.rao,

I suggest you to please try using following sample code on your end.

    public static void AddTextandImage()
    {
        String path = @"C:\Aspose Data\";
        Presentation pres = new Presentation();
        ISlide slide = pres.Slides[0];

        IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 0, 0, 150, 30);

        System.Drawing.Image img = (System.Drawing.Image)new Bitmap("aspose-logo.jpg");
        IPPImage imgx = pres.Images.AddImage(img);

        ashp.FillFormat.FillType = FillType.Picture;

        ashp.FillFormat.PictureFillFormat.Picture.Image = imgx;

        ITextFrame text=ashp.AddTextFrame("");

        text.Paragraphs[0].Portions[0].Text = "Sample text";

        pres.Save("C:\\Aspose Data\\Saved.pptx", Aspose.Slides.Export.SaveFormat.Pptx);


    }

#14

Please see attached output. Text not coming on imagequestion 2.png (46.1 KB)
.
Thank you
Annadatha.


#15

sorry for that

This is what I have tried

        IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 0, 0, 150, 30);

        System.Drawing.Image img = (System.Drawing.Image)new Bitmap(@"G:\EPIANCE\CURRENT WORK\work\epiance 21-01-2019\Simulate_Using_Aspose\images\image1.bmp");
        IPPImage imgx = pres.Images.AddImage(img);

        ashp.FillFormat.FillType = FillType.Picture;

        ashp.FillFormat.PictureFillFormat.Picture.Image = imgx;

        ITextFrame text = ashp.AddTextFrame("");

        text.Paragraphs[0].Portions[0].Text = "Sample text";

image 3.png (1.3 KB)

Uploaded image for your reference.

Thank you,
Annadatha.


#16

@annadatha.rao,

I suggest you to please try using following sample code on your end to serve the purpose. I have also attached source image as well as generated presentation for your reference as well.

    public static void AddTextandImage()
    {
        String path = @"C:\Aspose Data\";
        Presentation pres = new Presentation();
        ISlide slide = pres.Slides[0];

        IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 0, 0, 200, 50);

        System.Drawing.Image img = (System.Drawing.Image)new Bitmap(@"C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg");
        IPPImage imgx = pres.Images.AddImage(img);

        ashp.FillFormat.FillType = FillType.Picture;

        ashp.FillFormat.PictureFillFormat.Picture.Image = imgx;

        ITextFrame text=ashp.AddTextFrame("");

        text.Paragraphs[0].Portions[0].Text = "Sample text";


        //if there are multiple shapes i.e One with text and other with image
        //You can then set shape order to set the shapes behind or infront
        //Bring to front
        slide.Shapes.Reorder(slide.Shapes.Count - 1, ashp);
        //send to back
        slide.Shapes.Reorder(0, ashp);

        pres.Save("C:\\Aspose Data\\Saved.pptx", Aspose.Slides.Export.SaveFormat.Pptx);


    }

savedpres.zip (792.9 KB)
Jellyfish.jpg (711.6 KB)


#17

Hi fayyaz,

Unable to download samples. Can you please enable.

Thank you,
Annadatha.


#18

message is Sorry, this file is private. Only visible to topic owner and staff members.

Annadath.


#19

@annadatha.rao,

Please download the requested files from following link.

https://drive.google.com/open?id=1pEhaOzY1WcTdKGutu0FXzNspgB7aDSJt
https://drive.google.com/open?id=17zZrUeiZpPn_yaw7IIPkoRlz2E149P7Q


#20

Hi fayyaz,

Sample works, many many thanks for you. God bless you.

Thank you,
Annadatha.