• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Create a 1 pdf of assets not using an app first
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Create a 1 pdf of assets not using an app first


  • Subject: Re: Create a 1 pdf of assets not using an app first
  • From: "Vincent Angeloni M.D." <email@hidden>
  • Date: Sun, 06 May 2012 13:40:02 -0500

You will need a little external help for Applescript to coordinate this.
Use something like Image Events or Imagine Photo (http://www.yvs.eu.com/imaginephoto.html) to resize the 
images, if necessary. 

For the PDF part, my suggestion will involve a bit of a learning curve because it involves learning some Ruby, but hey, you're the one who
wants "free". Download Prawn, a RubyGem for creating PDF files -- it will do exactly what you need.
(http://prawn.majesticseacreature.com/) You can even use Prawn to scale the graphics, I think. So your basic
workflow would be to use Applescript to get the list of filenames, which you would then pass to a 
Ruby script which would do the actual PDF creation. You can try to run the Ruby script from a 
"do shell" in Applescript, but the quoting and escaping that ensues is a world of hurt. You are much
better off storing a version of the Rubyscript in a text file with placeholder text for the file lists which
Applescript will substitute in. Those Applescript lists need to be converted to a form Ruby understands (not difficult).
Then you can just read in the Ruby script into Applescript from the text file, "search and replace" your
placeholder text with the applescript variables you want in there and then save the text file somewhere (as a .rb file) and
make it executable. Run it from Applescript using: do shell script "MacHD/Users/MyUser/myRubyScript.rb"
Move the Ruby executable to the trash when done.

Here is a simple example I created quite a while back to make small PDFs which would fit onto the iphone
http://forums.supercard.us/viewtopic.php?f=17&t=53&p=290&hilit=vince#p290
And here is the entire script which was created to take text from Supercard and insert it into a text only PDF sized for the iPhone:

#!/usr/bin/env ruby
require 'rubygems'
require "prawn"

x = <<BIG_STRING_DELIM
xxxINSERTED_TEXTxxx
BIG_STRING_DELIM
# margins in the next line seem to be pixels...
pdf = Prawn::Document.new(:page_size => "A6", :page_layout => :portrait, :left_margin => 20, :right_margin => 20, :top_margin => 20, :bottom_margin => 35)
pdf.font "Helvetica"
pdf.text "TITLE_OF_DOCUMENT_HERE \n", :size => 18
pdf.text "AUTHOR_HERE \n (c)2008", :size => 10
pdf.start_new_page
pdf.font "Helvetica"
pdf.text x, :size => 10
pdf.render_file "myPDF.pdf"
So you would, for example read in the script into an Applescript variable, then replace 'xxxINSERTED_TEXTxxx' with
the main body text, and replace "TITLE_OF_DOCUMENT_HERE" and "AUTHOR_HERE" then save the script as an executable
ruby (.rb) file and execute it from the command line as described above. Vióla.
Good luck!
vince



hi Shane, You're right, and I didn't explain it clearly. And it isn't easy :) I just want to avoid any commercial application to get it done. Any default app like preview would be OK to use or even pdfroff NAME pdfroff - create PDF documents using groff Many thanks for your comments, jan On 6 mei 2012, at 11:44, Shane Stanley wrote: > On 06/05/2012, at 6:56 PM, Jan-Bultereys wrote: > >> no feedback on this topic > > I'm still trying to come to grips with your comment that it "looks easy". I mean, you can describe any task in simple terms, and say it looks easy. (Take a few kg or plutonium... it looks easy...) > > But applications are written for a reason. And given that AppleScript, of all languages, was written basically as a way of driving applications rather than doing stuff itself, I'm a bit surprised at your expectations. > > -- > Shane Stanley <email@hidden> > 'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/> > > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > AppleScript-Users mailing list (email@hidden) > Help/Unsubscribe/Update your Subscription: > Archives: http://lists.apple.com/archives/applescript-users >

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Create a 1 pdf of assets not using an app first
      • From: Emmanuel LEVY <email@hidden>
  • Prev by Date: Re: Create a 1 pdf of assets not using an app first
  • Next by Date: Detect if third word in string contains a number
  • Previous by thread: Re: Create a 1 pdf of assets not using an app first
  • Next by thread: Re: Create a 1 pdf of assets not using an app first
  • Index(es):
    • Date
    • Thread