Reputation: 263
I've tried this example http://www.javabeat.net/javascript-communication-between-html-and-pdf-in-itext/
So I have PDF with embeded javascript and with input fields in PDF.
When I tried to start(index.html for example) on my computer in IE11, than everything works. So when I enter name and loginname and click on send to PDF, than input fields in PDF are filled. But when I tried this example in chrome, than nothing happens.
I tried to debugging javascript and error which I give but after scrolling the page(without scrolling I don't have error) is this:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null')
Upvotes: 0
Views: 595
Reputation: 77606
I am the original author of the article you refer to. That code works because you are using the Adobe Reader plug-in in MSIE. It doesn't work with Chrome because Chrome uses the Chrome PDF Viewer to render PDF. It won't work in Firefox either because Firefox uses pdf.js. It won't work on a Mac either because the default PDF viewer on Apple computers is Preview.
The example you refer too depends on whether or not JavaScript is supported in the viewer, and if it's supported, whether or not you can create a message handler. To my knowledge only Adobe Reader (and Acrobat) meet these requirements.
The code you copied from my book won't work in Chrome's PDF viewer, pdf.js, nor Apple preview. There is no workaround to make it work with those viewers.
Upvotes: 1