Code makes no sense.
window.close(); // the CURRENT WINDOW is now closed...NO OTHER CODE can use the current window
// so this next line is meaningless, since the current window no longer exists.
// this next code might work, but it might not...
// ...because once the current window is closed where is the JS code supposed to be working?
If you want to close the current popup, that must be the *LAST* thing you do.
But what I don't understand is where the PDF file you say the middle statement opens is supposed to go if you are (a) trying to put it into the current window [which is what
will do] and (b) trying to close the current window.
That just makes no sense, at all.