Tuesday, March 20, 2012

PDF Displaying Blank Page In Javascript Popup window

The company I work for uses Adobe Livecycle for workflow management.  We also have a web front-end that acts as a proxy for user interaction with these workflows.  The web front-end will call the Livecycle APIs to generate a PDF and display it to a user.

Recently I was asked to display one of these PDFs in a separate window.  Pretty simple task right?  I wrote a little bit of Javascript with some window.open goodness and tested it out in IE7 (our standard).  Blank page.  Crap.

Turns out with a little bit of searching, IE7 and Adobe Reader don't play nice together when opening up a PDF in a new window created by Javascript.  Many people had the issue with the most common resolution to just create a link with a blank target.  That didn't quite suit my needs.  So here's my resolution.

The window.open command can take in an optional URL.  Instead of putting the URL of the PDF in the original window.open command I did something similar to the following:

var childWin = window.open('', 'windowname', 'other options');
childWin.location.replace('url of PDF');


By opening up the window with a blank page and then immediately doing a location.replace on the child window I was able to successfully bring up the PDF.

Hope that helps!

Wednesday, March 14, 2012

Bad Interpreter - No such file or directory

I ran into an issue with a shell script not functioning, getting the following error:

bad interpreter: no such file or directory

I verified that the shell was located at /bin/sh.  I then remembered that a colleague of mine made some changes to the script a few days earlier...on Windows...then moved it back.  Hmm.  Linebreaks ended up being the issue.

I ran

dos2unix filename

and the scripts ran just fine.

Hope that helps someone.