Free Support Forum - aspose.com

Where to find the demo code for ppt2pdf

I can not find it , can someone point it to me ,thanks !

Dear skyrunner,

Thank you for using Aspose.Slides.

If you are Aspose.Slides for JAVA user, then you can take advantage of Slide.saveToSVG method. This method saves the slide into SVG format, which you then insert into your PDF using iText + Batik library.

iText

http://www.lowagie.com/iText/

Batik

http://xmlgraphics.apache.org/batik/

Below is the code example to save slide to SVG format.

try

{

//Instantiate a Presentation object that represents a PPT file

Presentation pres = new Presentation(new FileInputStream(new File("demo.ppt")));

//Accessing a slide using its slide position

Slide slide = pres.getSlideByPosition(1);

//Saving to SVG format

FileOutputStrem fout=

slid.saveToSVG(new FileOutputStrem(new File("c:\\SlideImage.svg")));

}

catch(Exception ex)

{

System.out.println(ex.toString());

}

For adding the SVG to your PDF document, please see this code, which I took from this post.

http://www.aspose.com/Community/Forums/thread/76251.aspx

PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("image.test.pdf"));

document.open();

int width = 800;

int height = 600;

PdfContentByte cb = writer.getDirectContent();

PdfTemplate template = cb.createTemplate(width,height);

Graphics2D g2 = template.createGraphics(width,height);

PrintTranscoder prm = new PrintTranscoder();

TranscoderInput ti = new TranscoderInput("520.svg");

prm.transcode(ti, null);

PageFormat pg = new PageFormat();

Paper pp= new Paper();

// bunch of paper options here

ImgTemplate img = new ImgTemplate(template);

document.add(img);

document.close();

If you are Aspose.Slides for .NET user, then you can take the slide image and insert into your PDF document using Aspose.PDF

For a code example of taking Slide Image, see this link

http://www.aspose.com/wiki/default.aspx/Aspose.Slides/CreatingSlideThumbnail.html

For inserting image in PDF document using Aspose.PDF, please see this link

http://www.aspose.com/Community/Forums/2417/ShowPost.aspx

http://www.aspose.com/Community/Forums/5874/ShowPost.aspx