[java] Office docs -> pdf preview conversion

Hello.


Conversion from office document formats to PDF takes a lot of time for preview functionality.

Our current implementation is based on the sample below:


InputStream pptPresentationStream = ClassLoader.class.getResourceAsStream("/presentation.ppt");
Presentation pres = new Presentation(pptPresentationStream);
pres.save(“converted.pdf”, SaveFormat.Pdf);


The issue is that the first page is displayed only when the whole pdf doc is saved.

The questions are:
1. Is it possible to limit conversion to first n pages? (How?)
2. Is it possible to get the first converted output stream data immediately and not after whole doc conversion? (How?)

Regards
Martin


Hi Martin,

I have observed your comments and like to share with you that it is possible to limit conversion of first n pages. Please try using following sample code on your end to serve the purpose. However, it is not possible to get the first converted output stream data immediately and not after whole presentation conversion.

Presentation Source = new Presentation("D:\\Test.pptx");
Presentation target = new Presentation();
//Set n here
int n=2;

for (int i = 0; i < n; i++)
{
target.getSlideSize().setType(Source.getSlideSize().getType());
target.getSlideSize().setSize(Source.getSlideSize().getSize());
ISlide slide = Source.getSlides().get_Item(i);
target.getSlides().addClone(slide);
}
target.getSlides().removeAt(0);
target.save("D:\\2Slides.pdf", SaveFormat.Pdf);

I hope this will be helpful. Please share if I may help you further in this regard. Also, this thread has been moved to Aspose.Slides forum.

Best Regards,