def create_thumbnail_in_notes_slides_view(dataDir):

        # Instantiate Presentation class that represents the presentation file
        pres = Presentation(dataDir + 'demo.pptx')

        # Access the first slide
        slide = pres.getSlides().get_Item(0)

        # User defined dimension
        desired_x = 1200
        desired_y = 800

        # Getting scaled value  of X and Y
        scale_x = (1.0 / java_values(
            pres.getSlideSize().getSize().getWidth())) * desired_x
        scale_y = (1.0 / java_values(
            pres.getSlideSize().getSize().getHeight())) * desired_y

        # Create a full scale image
        image = slide.getNotesSlide().getThumbnail(scale_x, scale_y)

        # Save the image to disk in JPEG format
        imageIO = ImageIO()
        imageIO.write(image, "jpeg", File(dataDir + "ContentBG_tnail.jpg"))

        print "Created thumbnail in notes slides view, please check the output file.".PHP_EOL
Пример #2
0
    def create_thumbnail_custom_size(dataDir):
        
        # Instantiate Presentation class that represents the presentation file
        pres = Presentation(dataDir + 'demo.pptx')

        # Access the first slide
        slide = pres.getSlides().get_Item(0)

        # User defined dimension
        desired_x = 1200
        desired_y = 800

        # Getting scaled value  of X and Y
        scale_x = (1.0 / java_values(pres.getSlideSize().getSize().getWidth())) * desired_x
        scale_y = (1.0 / java_values(pres.getSlideSize().getSize().getHeight())) * desired_y

        # Create a full scale image
        image = slide.getThumbnail(scale_x, scale_y)

        # Save the image to disk in JPEG format

        imageIO = ImageIO()
        imageIO.write(image, "jpeg", File(dataDir + "ContentBG_tnail.jpg"))

        print "Created thumbnail with custom size, please check the output file.". PHP_EOL
    def set_page_size_for_pdf(dataDir):

        dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/SizeAndLayout/'

        # Instantiate Presentation class that represents the presentation file
        pres = Presentation()

        # Set SlideSize.Type Property
        slideSizeType = SlideSizeType
        pres.getSlideSize().setType(slideSizeType.A4Paper)

        # Set different properties of PDF Options
        opts = PdfOptions()
        opts.setSufficientResolution(600)

        # Saving the presentation
        save_format = SaveFormat
        pres.save(dataDir + "Export.pdf", save_format.Pdf, opts)

        print "Set page size for pdf, please check the output file."
    def set_page_size_for_pdf(dataDir):
        
        dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/SizeAndLayout/'    
        
        # Instantiate Presentation class that represents the presentation file
        pres = Presentation()

        # Set SlideSize.Type Property
        slideSizeType = SlideSizeType
        pres.getSlideSize().setType(slideSizeType.A4Paper)

        # Set different properties of PDF Options
        opts = PdfOptions()
        opts.setSufficientResolution(600)

        # Saving the presentation
        save_format = SaveFormat
        pres.save(dataDir + "Export.pdf", save_format.Pdf, opts)

        print "Set page size for pdf, please check the output file."
    def set_size_and_type(dataDir):

        dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/SizeAndLayout/'

        # Instantiate Presentation class that represents the presentation file
        pres = Presentation(dataDir + 'demo.pptx')
        aux_pres = Presentation()

        slide = pres.getSlides().get_Item(0)

        # Set the slide size of generated presentations to that of source
        aux_pres.getSlideSize().setType(pres.getSlideSize().getType())
        aux_pres.getSlideSize().setSize(pres.getSlideSize().getSize())

        # Clone required slide
        aux_pres.getSlides().addClone(pres.getSlides().get_Item(0))
        aux_pres.getSlides().removeAt(0)

        # Saving the presentation
        save_format = SaveFormat
        pres.save(dataDir + "Slide_Size_Type.pptx", save_format.Pptx)

        print "Set slide size and type, please check the output file."
    def set_size_and_type(dataDir):
        
        dataDir = Settings.dataDir + 'WorkingWithSlidesInPresentation/SizeAndLayout/'    
        
        # Instantiate Presentation class that represents the presentation file
        pres = Presentation(dataDir + 'demo.pptx')
        aux_pres = Presentation()

        slide = pres.getSlides().get_Item(0)

        # Set the slide size of generated presentations to that of source
        aux_pres.getSlideSize().setType(pres.getSlideSize().getType())
        aux_pres.getSlideSize().setSize(pres.getSlideSize().getSize())

        # Clone required slide
        aux_pres.getSlides().addClone(pres.getSlides().get_Item(0))
        aux_pres.getSlides().removeAt(0)

        # Saving the presentation
        save_format = SaveFormat
        pres.save(dataDir + "Slide_Size_Type.pptx", save_format.Pptx)

        print "Set slide size and type, please check the output file."