Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Convert anything to PalmDoc format Apps
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!
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[30,122 views]  

Convert anything to PalmDoc format | 21 comments | Create New Account
Click here to return to the 'Convert anything to PalmDoc format' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
unix_path() handler unnecessary
Authored by: jolinwarren on Feb 25, '03 11:53:37AM
Hello,

Just wanted to say that you can probably remove your unix_path() handler. To get a proper (& compatible) UNIX path, the easiest way is to use

quoted form of the POSIX path of

So your line: set inputFile to (unix_path(aFile))

would become: set inputFile to quoted form of the POSIX path of aFile

Another example:
do shell script "pdftotext " & inputFile &
" /Users/username/Desktop/" & unix_path(newName) & ".txt"


becomes:
do shell script "pdftotext " & inputFile &
" /Users/username/Desktop/" & quoted form of the POSIX path of newName & ".txt"


NOTE: I haven't been able to try these modifications to the script, but I believe the "quoted form of the POSIX path" function does what you are trying to accomplish with unix_path(). An extremely helpful technote to refer to when dealing with UNIX (and particularly do shell script) in AppleScript is:

http://developer.apple.com/technotes/tn2002/tn2065.html

The example I've given above comes from the "dealing with Files" section. Hope this helps.

Cheers,
Jolin

[ Reply to This | # ]
/tmp?
Authored by: Enkerli on Feb 26, '03 09:36:15AM

Is it just me or is /tmp a better choice for the temp files?



[ Reply to This | # ]
Problems with Convert Anything to PalmDoc Format
Authored by: dslipp on Feb 25, '03 12:03:55PM

When I saw this hint, I did the "Dance of Joy" (much to my wife's amusement) since this is something I've been trying to work out on my own.

Unfortunately, I've run into some problems (Please, don't take the following as criticism, they're just notes to help torubleshoot the problem.) -

1. First, I found that I had to "sudo make install" to install both packages. (No big deal...)

2. When configuring xpdf, I got this error:

" configure: WARNING: Couldn't find X / Motif -- you will be able to compile pdftops, pdftotext, pdfinfo, pdffonts, and pdfimages, but not xpdf "

I wans't sure whether that was critical, so I continued.

3. When I tried it in Safari, Safari locked up. Since this kind of thing isn't unusual for Safari, it may not be involved.

4. When I tried it in Script Editor, it seemed to be working, but after entering the title in the dialog box, it threw a "Printing Error" dialog box at me. No error detials, just "Printing Error."

I really hope this helps troubleshoot the installation, as this is something I would LOVE to see working.

Dave

---
Dave



[ Reply to This | # ]
Problems with Convert Anything to PalmDoc Format
Authored by: evildrbob on Feb 25, '03 12:27:36PM

I had the same problem with configure and then the printing error.

One comment - the aconf2 file? After commenting out every line beginning with a "#" I was left with no code uncommented - here's my file:

/*
* aconf2.h
*
* This gets included by aconf.h, and contains miscellaneous global
* settings not directly controlled by autoconf. This is a separate
* file because otherwise the configure script will munge any
* #define/#undef constructs.
*
* Copyright 2002 Glyph & Cog, LLC
*/

/#ifndef ACONF2_H/
/#define ACONF2_H/

/*
* This controls the use of the interface/implementation pragmas.
*/
/#ifdef __GNUC__/
/#define USE_GCC_PRAGMAS/
/#endif/
/* There is a bug in the version of gcc which ships with MacOS X 10.2 */
/#ifdef MAC_OS_X_VERSION_MAX_ALLOWED/
/# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2/
/# undef USE_GCC_PRAGMAS/
/# endif/
/#endif/

/#endif/


Is this correct? It doesn't seem to make sense to comment everything out, but the instructions *did* say every line with a # in front of it.



[ Reply to This | # ]
Problems with Convert Anything to PalmDoc Format
Authored by: Deut3221 on Feb 25, '03 08:37:26PM

I'd really like to give this a try, but it is over my head. If someone figuures out how to get it working, and then feels brave kind, and very paitent :), I'd appreciate a few more help lines for us rookies. Thanks!!
-steve


---
<><



[ Reply to This | # ]
Problems with Convert Anything to PalmDoc Format
Authored by: ldrothny on Feb 26, '03 01:57:36PM
I had this problem as well and noticed that both xPDF and txt2pdbdoc are installed in /usr/local/bin which for most of us isn't pathed properly. Your choices are:
-move the xPDF files and txt2pdbdoc files to /usr/bin/ (not recommended)
OR
-set up your path to include /usr/local/bin (not sure the best tip for this)
OR what I did was modify the two lines that referenced the commands as follows:
do shell script "pdftotext "
becomes:
do shell script "/usr/local/bin/pdftotext "
AND
do shell script "txt2pdbdoc "
becomes:
do shell script "/usr/local/bin/txt2pdbdoc "
I also noticed that one of the lines contains:
Users/mdr/Desktop/
instead of:
Users/username/Desktop/
This needs to be replaced with YOUR user name.

After I did these simple things it worked! And I really love it! Thanks to the original poster of this tip.

[ Reply to This | # ]
Problems with Convert Anything to PalmDoc Format
Authored by: idiotben on Feb 26, '03 09:10:24PM

I get the same thing. No debug output at all.



[ Reply to This | # ]
Fink xPDF
Authored by: Enkerli on Feb 26, '03 09:41:25AM

xpdf is available as a fink package, which might save some troubles building it.
In fact, txt2pdbdoc should be easy to package, which would make a nice combination...



[ Reply to This | # ]
Fink xPDF
Authored by: evildrbob on Feb 26, '03 10:51:32AM

Actually there is a MakeDoc java GUI that I've been using for quite some time - it doesn't let you just print to a PDB, but it will convert any text file using MakeDoc. And the interface is simple and easy to use...



[ Reply to This | # ]
Convert anything to PalmDoc format
Authored by: lee1 on Feb 26, '03 10:00:01AM

Readers of this hint might also be interested in iSilo, which is a Palm app that costs a few $ but, I've found, is worth it. It reads doc files and its own compressed format that supports images, tables, and hyperlinks. There are free utilities for OSX that convert html pages to iSilo's format, so if the content that you want to put on your Palm is in html, this is a good tool.

I have some links here.



[ Reply to This | # ]
username can be auto-generated...
Authored by: ldrothny on Feb 26, '03 01:19:46PM
Instead of swapping username with your UNIX login, you can enter the following snippit everywhere you see username in the above script.

`echo $USER`

NOTE that those are not apostrophes, but the tick mark on the same key as
the tilde ( ~ ).

Anything between the ` ` will execute as a seperate shell command. Therefore the above command will echo the USER variable which will be the name you logged in as.

As an example, instead of:
do shell script "pdftotext " & inputFile & " /Users/username/Desktop/" & unix_path(newName) & ".txt"

You would put:
do shell script "pdftotext " & inputFile & " /Users/`echo $USER`/Desktop/" & unix_path(newName) & ".txt"

[ Reply to This | # ]
Help for Those Who Are Having Trouble
Authored by: robm3660 on Feb 26, '03 04:31:30PM

I think this is a terrific hint, but I had some trouble getting it to work. Here is a revised set of instructions, based on my experiences:

  1. Download txt2pdbdoc. Then, in the Terminal program, type tar xzvf txt2pdbdoc-1.4.2.tar.gz to unpack the archive. You can then compile and install it by issuing the following commands, one at a time: cd txt2pdbdoc-1.4.2, ./configure, make and sudo make install. (You must have the Developers' Tools CD installed.) Finally, you may need to move the resulting executable file to a folder that the shell will search by default: sudo mv /usr/local/bin/txt2pdbdoc /usr/bin. As always, if you are asked for a password, just type in yours.
  2. Get xpdf. There are two ways to do this: via Fink or via the source code. Since Fink currently only has an old version of xpdf (1.01), I recommend getting the source code. If you get the source code, here's what you need to do:
    • Unpack the archive just as before, by typing tar xzvf xpdf-2.01.tar.gz in Terminal.
    • Change to the xpdf folder with cd xpdf-2.01.
    • Now issue the command ./configure.
    • Now you need to fix that bug mentioned in the original hint. (Xpdf is actually supposed to be able to fix itself, but this doesn't seem to work.) But you don't need to comment everything out in aconf2.h. Instead, the lines:
      #ifdef __CNUC__
      #define USE_GCC_PRAGMAS
      #endif

      should become:
      //#ifdef __CNUC__
      //#define USE_GCC_PRAGMAS
      //#endif
    • If you plan to use xpdf, then type make. On the other hand, if you're only getting xpdf because of this hint, then you don't need to compile everything. This hint only uses a small command-line utility that comes with xpdf and that's all you really need. So type this in Terminal: make pdftotext. This way you'll only compile what you need.
    • If you simply typed make above, then type sudo make install now. Otherwise, you'll need to manually move the executable to a bin folder: sudo mv xpdf/pdftotext /usr/bin.
  3. Now copy & paste the following revised script into Script Editor:
    on open these_items
    repeat with aFile in these_items
    set inputFile to quoted form of the POSIX path of 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 & " /tmp/" & quoted form of the POSIX path of (newName & ".txt")
    --convert to pdb
    do shell script "txt2pdbdoc \"" & newName & "\" /tmp/" & quoted form of the POSIX path of (newName & ".txt") &
    " ~/Desktop/" & quoted form of the POSIX path of (newName & ".pdb")
    --delete text file
    do shell script "rm /tmp/" & quoted form of the POSIX path of (newName & ".txt")
    --delete print spool file
    do shell script "rm " & inputFile
    end repeat
    end open

    You will not need to make any changes.
  4. Save this as an Application, rather than as a compiled script. You can save it in your home folder under Library/PDF Services (making it available only to you) or in the main Library folder under PDF Services (making it available to all users on your computer). ->PDB is a good name, or perhaps ->Palm. You will need to create the PDF Services folder if it doesn't already exist.

Now the Print dialog of all OS X applications should be able to make a Palm PDB by using the PDF workflow button.



[ Reply to This | # ]
Help for Those Who Are Having Trouble
Authored by: dslipp on Feb 27, '03 12:18:31AM

Brilliant! Fantastic! Terrific! Outstanding!

Oh - by the way - it works!

Many, many thanks to everyone.

I am now officially a happy camper.

---
Dave



[ Reply to This | # ]
Can't Save Script?
Authored by: Deut3221 on Feb 27, '03 02:27:07AM

Thank you for the very detailed hint. When I paste the script into the script editor and attempt to save as an applet, I get an error message. It states that the script can not be compiled, so it can only be saved as a text file...

Sorry, but thank you 1000X for your help this far. :)



[ Reply to This | # ]
Re: Can't Save Script?
Authored by: robm3660 on Feb 27, '03 11:59:10AM

You'll need to click on "Check Syntax" in Script Editor before it will allow you to save the script as anything but a text file.

Also, there does appear to be a mistake in my script. The following line:

do shell script "txt2pdbdoc "" & newName & "" /tmp/" & quoted form of the POSIX path of (newName & ".txt") &

should be:

do shell script "txt2pdbdoc \"" & newName & "\" /tmp/" & quoted form of the POSIX path of (newName & ".txt") &

Sorry for the inconvenience.



[ Reply to This | # ]
Further Correction
Authored by: robm3660 on Feb 27, '03 12:12:20PM

It seems I'm having trouble getting that line to display correctly (although it looks just fine when I preview it). I guess I'll just have to try it another way.

This line:

do shell script "txt2pdbdoc ¶"" & newName & "¶" /tmp/" & quoted form of the POSIX path of (newName & ".txt") &

is the correct line, only change the paragraph marks (¶) to backslashes (\).



[ Reply to This | # ]
Getting closer
Authored by: Deut3221 on Feb 27, '03 08:11:45PM

Thank you for the hint. I got the script saved as an executable. When I print, the script stops abruptly and says, "Can't make "txt2pbddoc" into a real" (and the word "real" is in blue).

When I click 'edit', the Script opens, and it is stopped in the middle of the following line with the first words " & newName & " highlighted blue.

do shell script "txt2pdbdoc " / " & newName & " / " /tmp/" & quoted form of the POSIX path of (newName & ".txt") &

I logged into the root directory and looked in the temp file, and a text file is being created. However, it is not being converted into a doc file.

Like I said, I'm over my head in the deep end ... cluess how to swim :) Seems as if either (1) I still don't have the script quite right; or (2) the txt2pdbdoc script is not working. I'm not sure how to test out either option. Call me cluess! Thanks again for your patience and help.



[ Reply to This | # ]
This one works fine!!
Authored by: Mr_BigMac on Feb 28, '03 08:16:05AM

A great Thank You to all working on this nice script!
I just tried out the script and figured out how it works.
Here is the working one:

on open these_items
repeat with aFile in these_items
set inputFile to quoted form of the POSIX path of 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 & " /tmp/" & quoted form of the POSIX path of (newName & ".txt")
--convert to pdb
do shell script "txt2pdbdoc '" & newName & "' /tmp/" & quoted form of the POSIX path of (newName & ".txt") &
" ~/Desktop/" & quoted form of the POSIX path of (newName & ".pdb")
--delete text file
do shell script "rm /tmp/" & quoted form of the POSIX path of (newName & ".txt")
--delete print spool file
do shell script "rm " & inputFile
--delete printing folder in tmp file
do shell script "rm -d /tmp/printing.*"
end repeat
end open


I just changed the line:

do shell script "txt2pdbdoc "" & newName & "" /tmp/" & quoted form of the POSIX path of (newName & ".txt") &

to:

do shell script "txt2pdbdoc '" & newName & "' /tmp/" & quoted form of the POSIX path of (newName & ".txt") &

The part '" & newName & "' contains '...' and this is the function to use seperated words as a filename. Without them you can use single words only.

And I added a cleaning up command:

--delete printing folder in tmp file
do shell script "rm -d /tmp/printing.*"

Maybe someone can figure out how to prevent the replacement of an already existing pdb file in case unforunately you choose the same file name again.



[ Reply to This | # ]
The Script as it Should Have Been
Authored by: robm3660 on Feb 28, '03 11:07:23AM

I’ve had some trouble getting the script to show up correctly. Specifically, the backslashes haven't been showing up. I think I know how to fix that, so here is one more attempt to display the “txt2pdbdoc” line:

do shell script "txt2pdbdoc \"" & newName & "\" /tmp/" & quoted form of the POSIX path of (newName & ".txt") &

The following may also work, as suggested by Mr_BigMac:

do shell script "txt2pdbdoc '" & newName & "' /tmp/" & quoted form of the POSIX path of (newName & ".txt") &

[ Reply to This | # ]
It works!
Authored by: Deut3221 on Mar 01, '03 12:11:26AM

At last. It works. Thank you 100X for your help!!



[ Reply to This | # ]
Convert anything to PalmDoc format
Authored by: moofie on Jul 23, '06 10:30:07PM

OK, there's a reason I use MacOS X and not Linux. This sort of thing is that reason.

Could somebody a bit farther along the learning curve please help me out? I've gotten so far as to convince Fink to install xpdf (go me!) but I can't figure out what to do with the txt2pdbdoc folder I've got in the root of my hard drive. I can't figure out where I should put it in order for it to work.

I think I've got the ./configure part working correctly, but I can't understand the conventions of where the software is supposed to go, and (since I can't access /bin and such with my GUI) how to get it there.

I'm also a little perplexed as to which set of modifications suggested to the script are necessary to make this go.

Yes, I am clueless. Thanks for taking pity on me.

---
Why yes! I AM a rocket scientist!



[ Reply to This | # ]