Convert anything to PalmDoc format

Feb 25, '03 06:16:00AM

Contributed by: Anonymous

With the new PDF workflow command (see this hint)and a little AppleScripting, you can convert the text content of any file into a Palm-readable pdbdoc file. Read the rest of the article for the how-to...

[robg adds: I have not had the time to test this one...]

Here's how to do it:

  1. Get txt2pdbdoc. In the Terminal, cd to the txt2pdbdoc directory and type ./configure, make, then make install.

  2. Get xpdf. In the xpdf directory, open the aconf2.h file and comment out (with double slashes) all of the lines that begin with "#". There's a bug in the 10.2 version of gcc that this avoids. Next, still in the xpdf directory, type ./configure, make, then make install.

  3. Open up Script Editor, and enter the following:
    on open these_items
      repeat with aFile in these_items
        set inputFile to (unix_path(aFile))
        --get new file name
        repeat
          display dialog "Enter title of document:" default answer "Title"
          set newName to the text returned of the result
          if newName is not "" then exit repeat
        end repeat
        --convert to text
        do shell script "pdftotext " & inputFile & ¬
          " /Users/username/Desktop/" & unix_path(newName) & ".txt"
        --convert to pdb
        do shell script "txt2pdbdoc \"" & newName & ¬
          "\" /Users/mdr/Desktop/" & unix_path(newName) & ¬
          ".txt" & " /Users/username/Desktop/" & unix_path(newName) & ".pdb"
        --delete text file
        do shell script "rm /Users/username/Desktop/" & ¬
          unix_path(newName) & ".txt"
        --delete print spool file
        do shell script "rm " & inputFile
      end repeat
    end open
    
    on unix_path(mac_path)
      set unixpath to (POSIX path of mac_path)
      set chars to every character of unixpath
      repeat with i from 1 to length of chars
        if " !$&\"'*(){[|;<>?~` \\" contains ¬
        (item i of chars as text) then
          set item i of chars to "\\" & (item i of chars as text)
        end if
      end repeat
      return every item of chars as string
    end unix_path
    Replace "username" with your UNIX username.

  4. Save this as a compiled script called "->PDB" in ~/Library/PDF Services
To convert any file, open the Print dialog and click on the PDF Workflow icon, then select the "-> PDB option". After entering the title, a PDB file will be created on your desktop. Note: This won't work in Acrobat Reader, although it will work in Preview.

Thanks to those who contributed the hints on unix_path and PDF Workflow!

Comments (21)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030220222718501