Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Thu Oct 18, 2018 10:55 am

Hello, I am adding an image to IAutoShape. The code works fine on my machine but no images is displayed when I deploy the application to Ms Azure. The image is in folder Content\images.

Code is as follows:

Code: Select all
string outPutDirectory = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
string logoUrl = Path.Combine(outPutDirectory, "Content\\images\\logo.png");
 IAutoShape shapeLogo = firstSlide.Shapes.AppendShape(ShapeType.Rectangle, rectLogo);
 FormatPicture(shapeLogo, logoUrl, 0);

    private void FormatPicture(IAutoShape shape, string pictureUrl, int transparency)
        {
            shape.Fill.FillType = FillFormatType.Picture;
            shape.Fill.PictureFill.Picture.Url = pictureUrl;
            shape.Fill.PictureFill.FillType = PictureFillType.Stretch;
            shape.ShapeStyle.LineColor.Color = Color.Transparent;
            shape.Fill.PictureFill.Picture.Transparency = transparency;
        }


I have verified on Ms Azure and the image is very well present at
D:\home\site\wwwroot\Content\images\logo.png

Is there any way to set shape.Fill.PictureFill.Picture to take an image from Resources instead of providing the filePath?

This is very urgent and any help will be greatly appreciated.

Thanks and Regards

ProwessConsulting
 
Posts: 12
Joined: Tue Oct 02, 2018 9:16 pm

Fri Oct 19, 2018 8:56 am

Hi,

Thanks for your inquiry.
Please use below code to embed image in presentation.
Code: Select all
RectangleF rectLogo = new RectangleF(50, 50, 100, 100);
ppt.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, logoUrl, rectLogo);
ppt.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;


Sincerely
Anna
E- iceblue support team
User avatar

Anna.Zhang
 
Posts: 73
Joined: Thu Sep 27, 2018 3:20 am

Sun Oct 21, 2018 8:18 am

Hello,
I have tried the line of codes you sent and this works on my local machine.
When deployed to Ms Azure, I get the error that the image link is broken. Please refer to the attachment.
I have verified on Ms Azure and the images are present as per the attachment in my previous comment.

Please assist.

Thanks and Regards

ProwessConsulting
 
Posts: 12
Joined: Tue Oct 02, 2018 9:16 pm

Mon Oct 22, 2018 9:52 am

Hi,

Thanks for your feedback and sorry for the late reply as weekend.
It's strange, I tested your scenario on Azure, but didn't find the issue you mentioned. Due to the forum size limitation, I sent my testing application to you via email, please add the dlls from the latest Spire.Presentation Pack Hotfix Version:3.10.4 and deploy the application on your Azure to have a test. I am looking forward to your reply.

Sincerely
Anna
E- iceblue support team
User avatar

Anna.Zhang
 
Posts: 73
Joined: Thu Sep 27, 2018 3:20 am

Wed Oct 24, 2018 1:55 am

Hi,

Greetings from E-iceblue.
How is your issue going? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Anna
E-iceblue support team
User avatar

Anna.Zhang
 
Posts: 73
Joined: Thu Sep 27, 2018 3:20 am

Fri Oct 26, 2018 11:19 am

Dear Nina and Anna,
I hope you are fine.
Sorry I have been busy with another project and it's only today that I have been able to test the code you sent.
Thank you very much for sending the code and this one works when deployed to Azure.
My project is a c# WebApi one. It is a controller which returns the Powerpoint document to a UI coded in AngularJs.
Everything works fine when running the web application locally, it is only when deployed to Azure that the images are not displaying.

The code is as follows:

Code: Select all
string outPutDirectory = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
string logoUrl = Path.Combine(outPutDirectory, "Content\\images\\logo.png");
 IAutoShape shapeLogo = firstSlide.Shapes.AppendShape(ShapeType.Rectangle, rectLogo);
 FormatPicture(shapeLogo, logoUrl, 0);

    private void FormatPicture(IAutoShape shape, string pictureUrl, int transparency)
        {
            shape.Fill.FillType = FillFormatType.Picture;
            shape.Fill.PictureFill.Picture.Url = pictureUrl;
            shape.Fill.PictureFill.FillType = PictureFillType.Stretch;
            shape.ShapeStyle.LineColor.Color = Color.Transparent;
            shape.Fill.PictureFill.Picture.Transparency = transparency;
        }


I have verified if the images have been deployed correctly to Azure and indeed the images are present.

Do you perhaps have sample code for WebApi?


Thanks and Regards
Kirtee

ProwessConsulting
 
Posts: 12
Joined: Tue Oct 02, 2018 9:16 pm

Fri Oct 26, 2018 12:41 pm

Dear Kirtee,

Thanks for your feedback.
I noticed that the code you provided is your older method, which appends image by specifying a picture URL, but doesn’t actully append the image as resource into presentation. Please make sure that you were using the new method we provided before. If the issue still happens, please provide a sample WebAPI to help us better investigate your issue.
Sample code:
Code: Select all
Presentation ppt = new Presentation();
string logoUrl = Server.MapPath("logo.png");
//Append image
RectangleF rect = new RectangleF(50, 50, 100, 100);
ppt.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, logoUrl, rect);
ppt.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;
ppt.SaveToFile(Server.MapPath("result.pptx"), FileFormat.Pptx2013);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Fri Oct 26, 2018 2:41 pm

Hello Nina,

I have changed the implementation and I am now using the code you provided and the issue is now fixed! The images are being displayed correctly in Azure.

But I am not able to hide the borders of the shape as shown in the attachment.
I am using the code below:
Code: Select all
            slide.Shapes[shapeIndex].Line.FillFormat.FillType = FillFormatType.None;
            slide.Shapes[shapeIndex].Line.Style = TextLineStyle.None;


Can you please advise on how to hide the borders.

Thank you very much for your help.

Regards
Kirtee

ProwessConsulting
 
Posts: 12
Joined: Tue Oct 02, 2018 9:16 pm

Mon Oct 29, 2018 3:10 am

Hi,

Sorry for late reply as weekend.
After an initial test with the latest Spire.Presentation Pack Hotfix Version:3.10.4, I didn't reproduce the border line issue by using your code. Please check again if the shapeIndex is referred to the image shape correctly. And to help us further investigate the issue, please provide your image, better to provide your complete code which shows your issue. Thanks in advance.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Mon Oct 29, 2018 7:09 am

Hello Nina,
Thanks very much for your help.
Issues have been resolved.

Thanks and regards

ProwessConsulting
 
Posts: 12
Joined: Tue Oct 02, 2018 9:16 pm

Mon Oct 29, 2018 8:33 am

Dear Kirtee,

Glad to hear that.
If you need further assistance, just feel free to contact us.
Wish you all the best!

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.Presentation