static void Main(string[] args) { //Instantiate a Presentation class that represents the presentation file string MyDir = @"Files\"; using (Presentation pres = new Presentation(MyDir + "Slides Test Presentation.pptx")) { //Access the second slide ISlide sld = pres.Slides[1]; //Create a memory stream object MemoryStream SvgStream = new MemoryStream(); //Generate SVG image of slide and save in memory stream sld.WriteAsSvg(SvgStream); SvgStream.Position = 0; //Save memory stream to file using (Stream fileStream = System.IO.File.OpenWrite(MyDir + "PresentatoinTemplate.svg")) { byte[] buffer = new byte[8 * 1024]; int len; while ((len = SvgStream.Read(buffer, 0, buffer.Length)) > 0) { fileStream.Write(buffer, 0, len); } } SvgStream.Close(); } }
public static void Run() { //ExStart:CreateSlidesSVGImage // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD(); // Instantiate a Presentation class that represents the presentation file using (Presentation pres = new Presentation(dataDir + "CreateSlidesSVGImage.pptx")) { // Access the first slide ISlide sld = pres.Slides[0]; // Create a memory stream object MemoryStream SvgStream = new MemoryStream(); // Generate SVG image of slide and save in memory stream sld.WriteAsSvg(SvgStream); SvgStream.Position = 0; // Save memory stream to file using (Stream fileStream = System.IO.File.OpenWrite(dataDir + "Aspose_out.svg")) { byte[] buffer = new byte[8 * 1024]; int len; while ((len = SvgStream.Read(buffer, 0, buffer.Length)) > 0) { fileStream.Write(buffer, 0, len); } } SvgStream.Close(); } //ExEnd:CreateSlidesSVGImage }
public int ConvertirDiapositivasASVG(string nombreDiapositivas) { string rutaArchivoParaConvertir = UbicacionArchivoParaEnviar + nombreDiapositivas + ".pptx"; string rutaArchivoConvertido = UbicacionArchivosSVG + nombreDiapositivas; int numeroDiapositivas = 0; using (Presentation pres = new Presentation(rutaArchivoParaConvertir)) { numeroDiapositivas = pres.Slides.Count; for (var i = 0; i < numeroDiapositivas; i++) { ISlide sld = pres.Slides[i]; MemoryStream SvgStream = new MemoryStream(); sld.WriteAsSvg(SvgStream); SvgStream.Position = 0; using (Stream fileStream = File.OpenWrite(rutaArchivoConvertido + i + ".svg")) { byte[] buffer = new byte[8 * 1024]; int len; while ((len = SvgStream.Read(buffer, 0, buffer.Length)) > 0) { fileStream.Write(buffer, 0, len); } } SvgStream.Close(); } } return(numeroDiapositivas); }
static void Main(string[] args) { string FilePath = @"..\..\..\Sample Files\"; string srcFileName = FilePath + "Conversion.pptx"; string destFileName = FilePath + "Creating Slide SVG Image.svg"; //Instantiate a Presentation class that represents the presentation file using (Presentation pres = new Presentation(srcFileName)) { //Access the second slide ISlide sld = pres.Slides[1]; //Create a memory stream object MemoryStream SvgStream = new MemoryStream(); //Generate SVG image of slide and save in memory stream sld.WriteAsSvg(SvgStream); SvgStream.Position = 0; //Save memory stream to file using (Stream fileStream = System.IO.File.OpenWrite(destFileName)) { byte[] buffer = new byte[8 * 1024]; int len; while ((len = SvgStream.Read(buffer, 0, buffer.Length)) > 0) { fileStream.Write(buffer, 0, len); } } SvgStream.Close(); } }