tab 1
此演示向您展示如何将 powerpoint 文档 ( ppt/pptx ) 转换为 pdf、html、图像、xps 和 tiff。
upload
maximum file size: 1 mb. files accepted: ppt , pptx.
click here to browse files.
fileerrors
convert to
source file:
filename
target file type:
e-iceblue
如果这不是您想要的 demo,您可以通过填写表格获取免费定制 demo。
如您有与我们产品相关的其他技术问题,请联系 该email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用javascript。;销售相关的问题,请联系 该email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用javascript。。
tab 2
package ppt;
import com.spire.presentation.fileformat;
import com.spire.presentation.presentation;
import javax.imageio.imageio;
import java.awt.image.bufferedimage;
import java.io.file;
public class convertdemo {
public void convertdemo(string filepath, string convertto, string resultfilename) throws exception {
presentation presentation = new presentation();
presentation.loadfromfile(filepath);
convertformat(presentation, convertto,resultfilename);
}
private void convertformat(presentation presentation, string convertto, string resultfilename) throws exception {
switch (convertto){
case "pdf":
presentation.savetofile(resultfilename ".pdf", fileformat.pdf);
break;
case "html":
presentation.savetofile(resultfilename ".html",fileformat.html);
break;
case "image":
bufferedimage[] images = new bufferedimage[presentation.getslides().getcount()];
for (int i = 0; i< presentation.getslides().getcount();i ){
images[i] = presentation.getslides().get(i).saveasimage();
}
if (images != null && images.length > 0){
if (images.length == 1){
imageio.write(images[0],".png", new file(resultfilename ".png"));
}
}else {
for (int j = 0; j < images.length;j ){
string filename = string.format("image-{0}.png",j);
imageio.write(images[j],".png",new file(filename));
}
}
break;
case "xps":
presentation.savetofile(resultfilename ".xps",fileformat.xps);
break;
case "tiff":
presentation.savetofile(resultfilename ".tiff",fileformat.tiff);
break;
}
}
}
tab 3
using spire.presentation;
using system;
using system.drawing;
using system.drawing.imaging;
namespace demoonlinecode
{
class convertors
{
public void democonvert(string filepath, string format, string resultfilename)
{
presentation presentation = new presentation();
presentation.loadfromfile(filepath);
convertformat(presentation,format,resultfilename);
}
private static void convertformat(presentation presentation, string format, string resultfilename)
{
switch (format)
{
case "pdf":
presentation.savetofile(resultfilename ".pdf", fileformat.pdf);
break;
case "html":
presentation.savetofile(resultfilename ".html", fileformat.html);
break;
case "image":
image[] images = new image[presentation.slides.count];
for (int i = 0; i < presentation.slides.count;i )
{
images[i] = presentation.slides[i].saveasimage();
}
if (images != null && images.length > 0)
{
if (images.length == 1)
{
images[0].save(resultfilename ".bmp", system.drawing.imaging.imageformat.bmp);
}
else
{
for (int i = 0; i < images.length; i )
{
string filename = string.format("{0}-image-{1}.png", resultfilename, i);
images[i].save(filename, imageformat.png);
}
}
}
break;
case "xps":
presentation.savetofile(resultfilename ".xps", fileformat.xps);
break;
case "tiff":
image[] images2 = new image[presentation.slides.count];
if (images2 != null && images2.length > 0)
{
for (int i = 0; i < presentation.slides.count; i )
{
images2[i] = presentation.slides[i].saveasimage();
}
jointiffimages(images2,resultfilename ".tiff", encodervalue.compressionlzw);
}
break;
}
}
private static imagecodecinfo getencoderinfo(string mimetype)
{
imagecodecinfo[] encoders = imagecodecinfo.getimageencoders();
for (int j = 0; j < encoders.length; j )
{
if (encoders[j].mimetype == mimetype)
return encoders[j];
}
throw new exception(mimetype " mime type not found in imagecodecinfo");
}
public static void jointiffimages(image[] images, string outfile, encodervalue compressencoder)
{
//use the save encoder
system.drawing.imaging.encoder enc = system.drawing.imaging.encoder.saveflag;
encoderparameters ep = new encoderparameters(2);
ep.param[0] = new encoderparameter(enc, (long)encodervalue.multiframe);
ep.param[1] = new encoderparameter(system.drawing.imaging.encoder.compression, (long)compressencoder);
image pages = null;
int frame = 0;
imagecodecinfo info = getencoderinfo("image/tiff");
foreach (image img in images)
{
if (frame == 0)
{
pages = img;
//save the first frame
pages.save(outfile, info, ep);
}
else
{
//save the intermediate frames
ep.param[0] = new encoderparameter(enc, (long)encodervalue.framedimensionpage);
pages.saveadd(img, ep);
}
if (frame == images.length - 1)
{
//flush and close
ep.param[0] = new encoderparameter(enc, (long)encodervalue.flush);
pages.saveadd(ep);
}
frame ;
}
}
}
}