Script to export power point/keynote presentation with formatting

I want to automate exporting power point/keynote presentations to a PDF (or word/pages) but formatted so text wraps around images. I've attached an example below. Basically I'm trying to minimize the number of pages and attempt to make the presentation more like a handout.


Thanks for any help y'all can provide


User uploaded file

Mac OS X (10.5.8)

Posted on Aug 21, 2014 9:09 AM

Reply
4 replies

Aug 24, 2014 10:09 PM in response to kevnm67

Keynote has an export command that will export a presentation to a number of formats, including PDF.


The following AppleScript creates a PDF file containing each slide as a 'page' in the PDF document. The formatting should match whatever the slides look like:


tell application "Keynote"

export document 1 as PDF to file ((path to desktop as text) & "presentation.pdf")

end tell

Aug 25, 2014 12:44 PM in response to Camelot

Thanks but I want to include formatting the text and including images in line with the content. I want to do something like the following but include images and open it in word or pages



-- Make sure a presentation is opened in Keynote. If not, notify the user and stop.

tell application "Keynote"

if (front document exists) = false then

display alert "Unable to proceed." message "Please open a presentation in Keynote."

return

end if


set extractBody to button returned of (display alert "Would you like to extract slide content too?" buttons {"Yes", "No"}) = "Yes"



-- Target the front presentation.

tell front document


-- Get the name of the presentation.

set thePresentationName to name



-- Retrieve the titles of all slides.

set theTitles to object text of default title item of every slide



-- If specified, retrieve the body text of all slides

if extractBody = true then

set theBodyText to object text of default body item of every slide

end if



-- Retrieve the presenter notes for all slides.

set theNotes to presenter notes of every slide

end tell

end tell


-- Prepare the notes as HTML.

set theFormattedNotes to "<html><body><h1>" & "" & thePresentationName & "</h1>" & return

repeat with a from 1 to length of theTitles


set theFormattedNotes to theFormattedNotes & "<h3>Slide #" & a & "</h3>" & return

set theFormattedNotes to theFormattedNotes & "<b>" & itema of theTitles & "</b>" & return & return

if extractBody = true then

set theFormattedNotes to theFormattedNotes & "<b>•</b>" & itema of theBodyText & return & return

end if

set theFormattedNotes to theFormattedNotes & "<b>Presenter Notes:</b> " & item a of theNotes & return & return

end repeat

set theFormattedNotes to theFormattedNotes & "</body></html>"


-- Replace any returns with line breaks.

set AppleScript'stext item delimiters to {return, ASCII character 10}

set theFormattedNotes to text items of theFormattedNotes

set AppleScript'stext item delimiters to "<br>"

set theFormattedNotes to theFormattedNotes as string

set AppleScript'stext item delimiters to ""


-- Create the note in Evernote.

tell application "Evernote"


activate

set theNote to create notenotebook "Inbox" titlethePresentationNamewith htmltheFormattedNotes


open note windowwiththeNote

end tell

Aug 25, 2014 11:55 PM in response to kevnm67

That is way beyond what your original post requested.


Your script is essentially trying to create a HTML document for each slide. In order to do that you're going to have to delve far, far deeper into the HTML formatting, probably building on some CSS properties to handle the formatting since simple HTML doesn't account for that.


Given the pretty radical differences between Keynote/Powerpoint layout tools and HTML, this is not something I'd approach lightly. How many presentations/slides do you have to cover? Have you considered recreating them in an HTML authoring package?

Aug 28, 2014 6:16 PM in response to Camelot

Camelot, sorry for the delay, busy week.

I probably should have worded the post better and can change it if I need to. I was trying to keep it short and by "formatting" I thought it implied more than a simple export. Let me know and ill change it....


I dont necessarily want it in HTML although the posted script does a great job extracting + formatting text. I do want a formatted export similar to the first picture I posted.


How can extract the image files from each slide + add "slide_1" (or whatever slide they were extracted from) and scale them down 50%?

- last part would be justifying the images in line with the text from the same slide.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Script to export power point/keynote presentation with formatting

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.