We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PPT Document Is Not Like Original DOCX Document Using Aspose.Words and Aspose.Slides

I’m trying to set up some code to convert a Docx file into a pptx. I found this example on the aspose site
https://products.aspose.com/total/net/conversion/docx-to-ppt/

I added a variation of the code in the example and that didn’t work, so I created a stand alone project using a very simple word document and it still doesn’t work.
It does generate a PPT document but it is nothing like the original.

We have a license for Words already but I was using a trial version of Slides to test this. Not sure if that could be causing the issues?

I have attached the stand alone project to this ticket, any help/advice would be appreciated.

The project is too large to upload with both Words and Slides so I have uploaded it to dropbox and the link is - https://www.dropbox.com/s/41vkym7k4ymutp5/AsposeDocxToPPT_ASP.zip?dl=0

If that doesn’t work please let me know.

@josephallison there is not easy or direct way to convert DOCX to PPTX, but looks like thee bigger issue that you are facing is to load the HTML in the Slide, so I’m redirecting your query to Aspose.Slides forum where you receive proper guidance.

@josephallison,
Please share your output HTML and PPT files created by the application you provided.

I have uploaded the output directory for the application - DocxToPPTX_Output.zip (1.5 MB)

Base template is “SU_accred_workbook.docx”
then the output is “SU_accred_workbook.ppt”
the rest is the html that is generated when running the conversion

@josephallison,
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-43866

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

I’ve moved this forum thread to Aspose.Total forum. My colleagues from Aspose.Words team will also work on the issues related to DOCX to HTML conversion.

As a workaround, you can try DOCX to SVG to PPT conversion. The result will be much better.

Hi Andrey,

Is the “DOCX to SVG to PPT conversion” part of the aspose.Words code or is this in aspose.Slides?

Thanks

@josephallison,
You can use Aspose.Words to convert Word document pages to SVG images like this:

var options = new Aspose.Words.Saving.SvgSaveOptions
{
    PageSet = new Aspose.Words.Saving.PageSet(0)
};

var doc = new Aspose.Words.Document("example.docx");
doc.Save("image.svg", options);

API Reference: SvgSaveOptions Class

Using Aspose.Slides, you can add the SVG images to presentation slides like this:

using (var ppt = new Presentation())
{
    var svgContent = File.ReadAllText("image.svg");
    var svgImage = new SvgImage(svgContent);

    var pptImage = ppt.Images.AddImage(svgImage);

    ppt.SlideSize.SetSize(
        pptImage.Width, pptImage.Height, SlideSizeScaleType.DoNotScale);

    ppt.Slides[0].Shapes.AddPictureFrame(
        ShapeType.Rectangle, 0, 0, pptImage.Width, pptImage.Height, pptImage);

    ppt.Save("output.pptx", SaveFormat.Pptx);
}

Documents: Adding SVG to Presentations

Hi Andrey,

Thanks for the reply, is there anyway to do this in memory stream?

I have adjusted the first part of the code to inport a template/save it to memory stream but I’m unsire how to use this stream when converting to a SVG string?

The line:

var svgContent = File.ReadAllText("image.svg");

uses a hardcoded location/filename, but I do not wish to save the svg, so I would only have this in memory stream.

Aspose.Words.Document doc;
Stream stream = new MemoryStream(File.ReadAllBytes("**Some file path**\\template.docx"));

MemoryStream input = new MemoryStream();

var options = new Aspose.Words.Saving.SvgSaveOptions
{
    PageSet = new Aspose.Words.Saving.PageSet(0)
};

doc = new Aspose.Words.Document(stream);
doc.Save(input, options);

using (var ppt = new Aspose.Slides.Presentation())
{
    var svgContent = File.ReadAllText("image.svg");

    var svgImage = new SvgImage(svgContent);

    var pptImage = ppt.Images.AddImage(svgImage);

    ppt.SlideSize.SetSize(
        pptImage.Width, pptImage.Height, SlideSizeScaleType.DoNotScale);

    ppt.Slides[0].Shapes.AddPictureFrame(
        ShapeType.Rectangle, 0, 0, pptImage.Width, pptImage.Height, pptImage);

    ppt.Save("**Some file path**\\output.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}

@josephallison,
You can replace the code lines

var svgContent = File.ReadAllText("image.svg");
var svgImage = new SvgImage(svgContent);

with

input.Seek(0, SeekOrigin.Begin);
var svgImage = new SvgImage(input);

If it is not what you mean, please describe the issue you encountering in more detail.