Under Doug

Under Doug

Under Doug RSS Feed
 
 
 
 

Converting PDF to HTML for PocketPc

The up-to-date textbooks for courses offered by are only offered in PDF format. I frequently need to convert PDF files to HTML so I can read them on the screen without my eyes going squirrelly. It is generally more comfortable to sit on the couch and read with my PDA than at the PC.

Here is a script to convert pdf files into html suitable for viewing in firefox or with the PocketIe browser on PDAs running Windows Mobile. The html produced views nicely with Firefox on the Mac and PC, and will probably render nicely on Palm PDAs. The HTML output can also be used (as long as you don’t add a “-asxhtml” option to pdftohtml command) with MobiPocket Publisher 3.0 to create a Microsoft Reader (.lit) file. I have not been having much luck reading .lit files since I upgraded my Dell Axim X50 to Windows Mobile 5, so for now I am sticking with html.

#!/usr/bin/env sh
# this program converts the arguments, a list of pdf files, to html.
# it uses tidy to ensure the html is conforming and sed to remove the background
# colour (which otherwise makes the document unreadable on a PocketPC) and
# to remove &nbsb; characters, which are rather wasteful of space and interrupt
#the flow.
#
for file in $*
do
	pdftohtml -c -noframes  $file
	htmlfile=${file/.pdf/.html}
	tempfile=$(mktemp)
	mv $htmlfile $tempfile
	tidy -ashtml -utf8  -clean $tempfile | sed -e 's;background-color:.*;;g' -e 's# # #g' > $htmlfile
	rm $tempfile
done

I have run this on a mac, it would probably work on as well.

pdftohtml for some reason creates a grey background for documents, which looks horrible on my PDA, so the sed script above removes the grey background from the HTML produced by pdftohtml.

The tidy step removes the inline formatting, to decrease the size of the html. The sed script also replaces the   with plain old whitespace, to allow the text to flow more and decrease the file size.

If this looks like gobbledygook to you, you have probably underestimated the skill one seems to need to be able to read PDF documents in a reasonable fashion on a PocketPC. A computer science diploma or degree helps. It would be nicer if you could right click on a PDF document, select “make available in a PDA” option, and magically have a legible document available on your PDA, but it doesn’t work like that. PDFs are often hard to read on a PC, let alone a PDA, though palm users are apparently happier with Documents To Go. You can try adobe acrobat or foxit reader for your pda; I didn’t find these workable because they don’t present the text any better for online viewing on PDAs than they do on PCs.

Technorati Tags: , , , , , , , ,

3 Responses to “Converting PDF to HTML for PocketPc”

  1. doug Says:

    Received from Gord:

    I’d comment on your blog, but I’d have to create a WordPress account. So you get this in email instead (you can post it if you like). Here are some improvements to your shell script (in red). I assume the first line was for maximum portability,
    but sh will always be found in /bin/sh, so you don’t need to do the /usr/bin/env hack (which itself isn’t as portable as you think). Your for-line should use the “$@”
    variable instead of the “$*” variable, double-quoted, so you handle filenames with spaces in them correctly. The rest of the changes to the file areadding double-quotes around possible space-containing variables.

    #!/bin/sh
    # this program converts the arguments, a list of pdf files, to html.
    # it uses tidy to ensure the html is conforming and sed to remove the background
    # colour (which otherwise makes the document unreadable on a PocketPC) and
    # to remove &nbsb; characters, which are rather wasteful of space and interrupt
    #the flow.
    #
    for file in “$@”
    do
    pdftohtml -c -noframes “$file”
    htmlfile= “${file/.pdf/.html}”
    tempfile=$(mktemp)
    mv “$htmlfile” $tempfile
    tidy -ashtml -utf8 -clean $tempfile | sed -e ’s;background-color:.*;;g’ -e ’s# # #g’ > “$htmlfile”
    rm $tempfile
    done

    Gord.

  2. Under Doug » Blog Archive » Plucker on Windows Mobile Says:

    [...] At some point I plan to update the pdf to pda conversion script to convert to plucker as well as or instead of html. [...]

  3. Under Doug » Blog Archive » PDF Trials on Windows Mobile Says:

    [...] I have been using pdftohtml to convert pdf documents to html, and sometimes then to plucker, so I can use them on my PDA. I have been finding some PDFs just do not convert - most of the text is missing. Same result with pdftotext. [...]

Leave a Reply

You must be logged in to post a comment.

  • vitamin stores Online Without Prescription WorldWide Shipping. Low Prices.
  • Buy Cheapest ambien accept mastercard Online Best Online. Internet Prices For ambien accept mastercard!
  • Buy Cheap fluoxetine hcl Online 24/Internet)(safe Pharmacy. Best Online.
  • Buy Cheapest cialis compare viagra Online Buy Medications Online. Best Drugstore.
  • Buy Cheapest medications on line Now Pharmacy Store. Online Medical Shop.
  • Buy Cheapest viagra dosage Online Pharmacy Store. 24/Online Pharmacy.
  • Buy Cheap generic viagra from india Now Best Internet. Drugs, Health And Beauty.
  • Buy Cheapest cheapest drugs online Now 24/Online Pharmacy. Free Viagra Pills!
  • Buy Cheapest non prescription diuretic Online Special Prices For non prescription diuretic! Best Online.
  • Buy Cheap generic ambien without a prescription Now Cheap Pharmacy Online. Cheap Online Pharmacy.
  • Buy Cheap viagra ingredients Now 100% Satisfaction Guaranteed. Low Prices.
  • Buy Cheapest withdrawal ambien Online Best Online. Top Online Pharmacy.
  • buy phentermine cheap Online Without Prescription Best Internet. Best Prices.
  • Buying Cheap how to buy medicine from canada. Offshore Rx, Best Prices. Guaranteed Shipping.
  • Buy Cheap generic viagra online Now Cheap Pharmacy Online. No Prescription Needed.
  • Buy Cheap buy pain medicine on-line Now Safe And Secure Payment System. Best Prices.
  • Buy Cheapest presciption drugs sale online Online Guaranteed Shipping. Best Online.
  • Buy Cheap valium pregnancy Online 24/Online Pharmacy. Pharmacy Store.
  • Buy Cheapest cialis softabs Now WorldWide Shipping. Top Online Pharmacy.
  • Buy Cheap anxiety zoloft Now Drugs, Health And Beauty. Online Medical Shop.
  • xanax withdrawals Online Without Prescription Best Drugstore. Pharmacy Store.
  • Buy Cheap norvasc information Online Drugs, Health And Beauty. Best Prices.
  • Buy free sample prescription for viagra Without Prescription Doctor. Pharmacy At The Best Price!
  • Buy Cheap where to buy meclizine Now Online Medical Shop. WorldWide Shipping.
  • Buy Cheapest cialis interactions Now Best Prices. Order Cheap Meds Without Rx.
  • Buy Cheap levitra safety Now Free Viagra Pills! Guaranteed Shipping.
  • Buy Cheap online pharmacy for valium and soma Online Cheap Prescription Drugs. Best Online.
  • Buying Cheapest cialis usage. Offshore Pharmacy, Good Prices. Low Prices.
  • Buy Cheap top weight loss pills Online Internet Prices For top weight loss pills! Pharmacy Store.
  • Buy Cheapest mixing codeine with sleeping pills Online 24/Online Pharmacy. Best Prices.
  • Buy Cheap injecting valium tablets Now Top Online Pharmacy. Discount Pharmacy Online.
  • Buy Cheap cialis fast delivery Now Safe And Secure Payment System. Best Prices.
  • Buy Cheap but cialis online Online Best Drugstore. Internet Prices For but cialis online!
  • Buy Cheap natural pain killers Online Low Prices. Drugs, Health And Beauty.
  • Buy Cheap valium vs xanax Now Cheap Meds Without Prescription. Best Online.
  • Buy Cheapest long term anxiety treatment Online No Prescription Needed. Low Prices.
  • Buy Cheapest alprazolam online without prescription Online Internet Prices For alprazolam online without prescription! Low Prices.
  • Buy Cheap weight loss medicine online prescrition Online Best Prices. Discount Online Pharmacy.
  • Buy Cheap viagra 50 mg Online Best Drugstore. 24/Online Pharmacy.
  • Buy Cheap pain relief prescription Now 24/Internet)(safe Pharmacy. Best Internet.
  • Buy Cheapest indian viagra Online Best Internet. 24/Online Pharmacy.
  • Buy Cheap order femara Online Pharmacy Store. Buy Medications Online.
  • Buying Cheapest tramadol cod online. Mexican Pharmacy, Good Prices. Best Prices.
  • Buy Cheap levitra and blood pressure Online Online Medical Shop. Free Viagra Pills!
  • Buy Cheap united pharmacy canada Online Best Drugstore. Buy Medications Online.
  • Buy Cheap to enhance effects of cialis Now The Largest Internet Pharmacy. Best Online.
  • Buy Cheap does vpxl work Now Order Cheap Meds Without Rx. Low Prices.
  • Buy Cheap promethazine hydrochloride Now Best Internet. 100% Satisfaction Guaranteed.
  • Buy Cheap generic propecia canada Now Internet Prices For generic propecia canada! Best Online.
  • Buy Cheapest diflucan oral Now Best Internet. Cheap Online Pharmacy.
  • Buy Cheap fastin diet pills cheap Now Best Drugstore. Drugs, Health And Beauty.
  • Buy Cheap prescribed medication for acne Now Guaranteed Shipping. Online Prices For prescribed medication for acne!
  • Buy Cheap fat burning pill Now Online Medical Shop. Discount Online Pharmacy.
  • Buy Cheap natural pain killer for tooth pain Online Cheap Prescription Drugs. Best Drugstore.
  • Buy Cheap cialis generic Now Top Online Pharmacy Supplier. Best Online.
  • Buy Cheapest what is lipitor Now Pharmacy At The Best Price! Best Online.
  • Buy Cheap hair loss pills Now Bonus Pills And Reorder Discounts! Low Prices.
  • Buy Cheapest meclizine hcl Now Cheap Pharmacy Online. Best Drugstore.
  • Buy Cheapest buy viagra online in uk Online Cheap Prescription Drugs. Best Internet.
  • Buy Cheapest discount pain relief Now Online Medical Shop. Cheap Pharmacy Online.
  • Buy Cheapest cialis by mail Now Top Online Pharmacy. Cheap Pharmacy Online.
  • Buy Cheap cheap levaquin Online Best Online. Order Cheap Meds Without Rx.
  • Buy Cheap low dose cialis Online Cheap Online Pharmacy. Pharmacy Store.
  • Buy Cheapest pain killer no prescription mexico Online Discount Online Pharmacy. Best Online.
  • Buy online consultation viagra Without Prescription Doctor. Low Prices. Best Online.
  • Buy Cheapest depression zyban Online Cheap Online Pharmacy. Low Prices.
  • Buy Cheap online pharmacies without prescription Now Order Cheap Meds Without Rx. Best Internet.
  • Buy Cheap valium low cost Now 100% Satisfaction Guaranteed. Best Drugstore.
  • Buy Cheap prescription pain relief medication Now Best Internet. Online Prices For prescription pain relief medication!
  • Buy Cheap canadian drugstore Now Special Prices For canadian drugstore! Best Prices.
  • Buy Cheapest medicine online Online Discount Pharmacy Online. Best Prices.
  • Buy Cheap proscar generic Now Cheap Pharmacy Online. Top Online Pharmacy.
  • Buy Cheapest nerve pain medication Online Best Internet. Online Prices For nerve pain medication!
  • Buy Cheap upper back pain products sale Now Online Medical Shop. Discount Pharmacy Online.
  • Buy Cheap diazepam delivered overnight Now WorldWide Shipping. No Prescription Needed.
  • Buy Cheapest order viagra soft Now Best Prices. No Prescription Needed.
  • Buy Cheap ambien free consultation Online Pharmacy Store. Cheap Online Pharmacy.
  • Buy Cheapest cheap medications Now Buy Medications Online. Best Drugstore.
  • Buy Cheap effects of clonazepam Online Discount Online Pharmacy. Best Drugstore.
  • phentermine 37.5mg tabs Online Without Prescription Online Medical Shop. Low Prices.
  • Buy Cheap online cod tramadol Now Top Online Pharmacy. Discount Online Pharmacy.
  • Buy Cheap viagra or cialis Online 24/Online Pharmacy. Top Online Pharmacy.
  • Buy weight loss programs online Without Prescription Doctor. Best Prices. Best Online.
  • Buy Cheapest cheapest viagra substitute sildenafil Now Internet Prices For cheapest viagra substitute sildenafil! Best Online.
  • Buy Cheap natural weight loss pill Now Drugs, Health And Beauty. Best Internet.
  • Buy Cheapest online sales viagra Online Best Drugstore. Online Medical Shop.
  • Buy Cheapest zoloft no prescription Now 100% Satisfaction Guaranteed. Best Prices.
  • Buy Cheapest lexapro vs celexa Now Pharmacy Store. Pharmacy At The Best Price!
  • Buy Cheapest tramadol check cod Online Best Prices. Drugs, Health And Beauty.
  • Buy Cheap buying prescription drugs online Now 24/Online Pharmacy. No Prescription Needed.
  • Buy Cheap valtrex cost Now Best Drugstore. Buy Medications Online.
  • Buy Cheap pain medication for sale Online Pharmacy At The Best Price! Best Online.
  • Buy Cheapest valtrex use Now Pharmacy Store. Pharmacy At The Best Price!
  • Buy Cheap appetite suppress tablet Now The Largest Internet Pharmacy. Low Prices.
  • Buy Cheapest eli lilly cialis Online Free Viagra Pills! Top Online Pharmacy.
  • Buy Cheap xanax perscription Online Best Internet. Cheap Pharmacy Online.
  • Buy Cheap amoxicillin diarrhea Now Cheap Pharmacy Online. WorldWide Shipping.
  • Buy Cheapest buy prescription drugs Now Pharmacy Store. Guaranteed Shipping.
  • Buy Cheap pmdd drugs Now Best Online. No Prescription Online Pharmacy.
  • Buy Cheap tramadol prescription drug Now Safe And Secure Payment System. Best Internet.