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.

Fri Apr 15, 2016 4:40 pm

Need full vb script to generate PPT and make it downloadable on client side - I'm using asp.net VS2010.

10Q!

kdr13
 
Posts: 72
Joined: Fri Apr 15, 2016 4:35 pm

Mon Apr 18, 2016 6:09 am

Hi,

Thanks for your interests in our Spire.Presentation.
I recommend you to use this method to generate PPT and make it download.
Code: Select all
Presentation.SaveToHttpResponse(string FileName, FileFormat fileFormat, System.Web.HttpResponse response);


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Tue Apr 19, 2016 7:56 am

Hi,

Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Wed Apr 20, 2016 5:10 pm

Thanks for the reply however the "response" part is not clear - What should be the exact syntax so the client will get a download message for this file?

Thanks!

kdr13
 
Posts: 72
Joined: Fri Apr 15, 2016 4:35 pm

Wed Apr 20, 2016 5:14 pm

I was able to fix that however when downloading the file and opening it on the client side with MS-PowerPoint the client gets a message that the file is corrupted and should be fixed. Any solution? 10Q!

kdr13
 
Posts: 72
Joined: Fri Apr 15, 2016 4:35 pm

Thu Apr 21, 2016 4:01 am

Hi,

Thanks for your reply.
Please share the code you are using to help us check your issue. So that we can work out solution soon for you.
Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Thu Apr 21, 2016 11:24 am

Here's the vb script triggered from a button:
'create PPT document
Dim presentation As New Presentation()

'add new shape to PPT document
Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(0, 50, 200, 50))

shape.ShapeStyle.LineColor.Color = Color.White
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None

'add text to shape
shape.AppendTextFrame("Hello World!")

'set the Font fill style of text
Dim textRange As TextRange = shape.TextFrame.TextRange
textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid
textRange.Fill.SolidColor.Color = Color.Black
textRange.LatinFont = New TextFont("Arial Black")

'Stream the file to client for download
presentation.SaveToHttpResponse("hello.pptx", FileFormat.Pptx2010, Response)

I get a message when opening the file on the client side with MS-PowerPoint that MS-PowerPoint found a problem in the contents of this file and can try to fix it. At that point I can either select "Fix" or "Cancel". If I press "Fix" I get a another message that MS-PowerPoint cannot open this file and I'm asked if I'd like to search for a converter in Office.com that enables opening the file. I select "Open" and then the file is opened in MS-PowerPoint.

Any suggestions how to fix this? Thanks again!

kdr13
 
Posts: 72
Joined: Fri Apr 15, 2016 4:35 pm

Fri Apr 22, 2016 6:36 am

Hi,

Thanks for your sharing.
I have replicated the issue with your code, so sorry for the inconvenience the issue brought to you. I have forwarded it to our dev team. We will inform you when it is fixed. I provide you another solution to download .pptx file, welcome to try.
Code: Select all
        byte[] data= null;
            using (MemoryStream ms = new MemoryStream())
            {
                presentation.SaveToFile(ms, FileFormat.Pptx2010);
                data = ms.ToArray();
            }
            Response.Clear();
            Response.AddHeader("Content-Type", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
            Response.AddHeader("Content-Disposition", "attachment;filename=sample.pptx");
            Response.OutputStream.Write(data, 0, data.Length);
            Response.End();


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Sun Apr 24, 2016 5:29 am

Thank you - I will try this snippet.

Few more other questions:
1. What is the syntax for setting a parameterized font type? I have a dropdown box in my asp.net page from which the user selects the font type (Arial, David etc.) and I would like to font showing in the generated slides to match the user's selection.
2. How do I set the font size?
3. How do I set the text range size in a slide?
4. How do I set "wrap text"?
5. How do I set left text indent left?

Thank you again!

kdr13
 
Posts: 72
Joined: Fri Apr 15, 2016 4:35 pm

Mon Apr 25, 2016 3:32 am

Hi,

Thanks for your further inquiry.
I provide you a demo as below to show the settings you need.
Code: Select all
             Presentation presentation = new Presentation();
             RectangleF rectangle = new RectangleF(0, 50, 200, 50);

            //3. Set the text range size in a slide by setting height of width of rectangle
            IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle,rectangle);

            shape.ShapeStyle.LineColor.Color = Color.White;
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;
            shape.AppendTextFrame("Hello World!");
            TextRange textRange = shape.TextFrame.TextRange;
            textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            textRange.Fill.SolidColor.Color = Color.Black;

            //1. Set the font type
            textRange.LatinFont = new TextFont("Arial Black");

            //2. Set the font size
            textRange.Format.FontHeight = 20;

           //4. Set "wrap text"
            shape.TextFrame.WordWrap = true;

           //5. Set text left indent
            shape.TextFrame.MarginLeft = 60;

            presentation.SaveToFile("sample.pptx",FileFormat.Pptx2010);


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Tue Apr 26, 2016 2:21 pm

Thanks a lot - What about item #1 and #3?

Thank you!

kdr13
 
Posts: 72
Joined: Fri Apr 15, 2016 4:35 pm

Tue Apr 26, 2016 4:06 pm

The Set text left indent does not work - the text in centralized. Please advise, TNX

kdr13
 
Posts: 72
Joined: Fri Apr 15, 2016 4:35 pm

Wed Apr 27, 2016 3:34 am

Hi,

For #1 and #3, my above solution has the code about them. Please check it again.
The Set text left indent does not work - the text in centralized.

I tested the code: shape.TextFrame.MarginLeft = 60 and it worked fine on my side.
Could you please share your code to help us check your issue? Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Wed Apr 27, 2016 8:09 am

Thanks - I will try to post the code/screeshot later.
Regarding item #1 - I didn't find any reference to parameterized settings: I would like to the font type to be set according to a value selected by the user from a dropdown list as explained earlier.

Thank you!

kdr13
 
Posts: 72
Joined: Fri Apr 15, 2016 4:35 pm

Wed Apr 27, 2016 8:44 am

Hi,

For item #1, please try this code:
Code: Select all
string fontname=this.dropDownListFonts.SelectedItem.ToString();
  textRange.LatinFont = new TextFont(fontname);


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Presentation