Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

125
Views
Populating images on a Keynote file using Javascript for Automation (JXA)

I would like to populate a keynote presentation with images that I have stored in my home directory.

Each image should go to one slide. I've looked a lot on the internet but I've only an example which doesn't work for me.

let app = Application('Keynote')

app.documents[0].currentSlide.images.push(app.Image({
  file: Path("/path/to/image.jpg")
}))

This is the script I've done up to now.

app = Application('Keynote')
app.includeStandardAdditions = true


doc = app.Document({
    documentTheme: app.themes['White']
});
app.documents.push(doc)

// Create and append a new "Title & Bullets" slide.
slide = app.Slide({
    baseSlide: doc.masterSlides['Title & Bullets']
});

doc.slides.push(slide);

slide.defaultTitleItem().objectText="Hello"

slide.defaultBodyItem().objectText="Test1\ntest2"

doc.slides.push(slide);

slide.images.push(app.Image({file: Path("~/a.jpg")}))

The script above creates the presentation correctly and adds the text as it should, but it fails to add the image.

Any help would be appreciated.

Thanks in advance.

Regards, Pedro

7 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.