Converting to PDF File

Skip to end of metadata
Go to start of metadata
PDF documents are widely used as a standard format of exchanging documents between organizations, government sectors and common users etc. So, it may also be required by the developers to convert their presentation files to PDF documents. Realizing this possible requirement, Aspose.Slides for Java has added the built-in support of converting presentations to PDF documents without using any other component.

Converting Presentation to PDF

Presentation class that represents the presentation expose s the s ave method that can be called by developers to convert the whole presentation into PDF document. Further, different options for creating the PDF are provided by the PdfOptions class such as JpegQuality , TextCompression , Compliance etc. These options can be used to ge t the desired standard of PDF.

Converting Presentation to PDF using default options

The following example shows how to convert a presentation into PDF document with default options. Default options create the PDF document with maximum quality.

Example

[Java]
try {

      //Instantiate a Presentation object that represents a PPT file
      Presentation pptPresentation = new Presentation("demo.ppt");

      //Saving the presentation to PDF document
      pptPresentation.save("demo.pdf",com.aspose.slides.export.SaveFormat.PDF);

   } catch (PptException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
   } catch (FileNotFoundException e) {
	 //TODO Auto-generated catch block
	e.printStackTrace();
   }


 

Converting Presentation to PDF using custom options

The following example shows how to convert a presentation into PDF document with customized options as provided by PdfOptions class.

Example

[Java]
try {

     //Instantiate a Presentation object that represents a PPT file
     Presentation pptPresentation = new Presentation("demo.ppt");

     //Instantiate the PdfOptions class     
     com.aspose.slides.export.PdfOptions pdfOptions=new com.aspose.slides.export.PdfOptions();

     //Set Jpeg Qualit
     pdfOptions.setJpegQuality(90);

     //Define behavior for metafiles
     pdfOptions.setSaveMetafilesAsPng(true);

     //Set Text Compression level	
     pdfOptions.setTextCompression(com.aspose.slides.export.PdfTextCompression.FLATE);

     //Define the PDF standard
     pdfOptions.setCompliance(com.aspose.slides.export.PdfCompliance.PDF_15);

     //Save the prsentation to PDF with specified options
     pptPresentation.save("demo.pdf", com.aspose.slides.export.SaveFormat.PDF,pdfOptions);
			
   } catch (PptException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
   } catch (FileNotFoundException e) {
	 //TODO Auto-generated catch block
	e.printStackTrace();
   }

 
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.