Friday, October 25, 2013

PDFs, iText and taskkill, oh my!

Acrobat Reader isn't exactly convenient to developers working to send PDFs for printing. The solutions I  dug up are mostly unofficial, and an outdated PDF at best. And I just recently found out from the user reviews that iText library is no friendly forces either. For all the solutions I could find, acrord32 is known to have at least one window open after all the operations are said and done. Which brings me back to the established solution in the system we're supporting: killing Acrobat Reader.

What the existing codes have been doing along was to trigger tskill via Runtime.exec in order to terminate the acrord32 process. That was all fine and dandy for what used to be WinXP. But the Tech Refresh introduced Win7 as a replacement for most of the machines. The JRE6 Java Console threw this out:
java.io.IOException: Cannot run program "tskill": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
Which basically means we're screwed because Win7 didn't know what the tskill program was. When I first turned to this article, I believed that