I am trying to use PDFObject to show the pdf files inline. The application may contain many files. All the files are shown in the list. On clicking any one of the file, the pdf should be viewable if browser contains the pdf plugin or else show some anchor tag to download the file.
The problem I am having is .. I couldn't figure out how to pass the file name from viewmodel to the script in the zul page.
This is what I have done so far..
<?page title="Auto Generated index.zul"?>
<?script type="text/javascript" src="pdfobject.js"?>
<window title="Hello World!!" border="normal" width="200px" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.shahukhalroshan.vm.DemoViewModel')" xmlns:w="http://www.zkoss.org/2005/zk/client">
<button label="ok" w:onClick="embedPDF()" />
<script type='text/javascript'>
function embedPDF(){
var myPDF = new PDFObject({
url: 'abc.pdf'
}).embed();
}
window.onload = embedPDF; //Feel free to replace window.onload if needed.
</script>
<div>
It appears you don't have Adobe Reader or PDF support in this web
browser. <a href="abc.pdf">Click here to download the PDF</a>
</div>
</window>