embed javascript to a jasper report pdf? - struts2

I want to embed a javascript function into a pdf file generated by jasper.
it comes to my mind because I want to make the pdf file auto open printing dialog.
after reading this question and tried this example I want to do the same.
but I use iReport designer to create my pdf templates and then export using struts actions, any idea how to embed javascript with ireport?
thanks

You can try to use the net.sf.jasperreports.export.pdf.javascript property.
The information about this property is here.

Related

How to open a file from Grails app using <a> tag?

This is my first Grails project & I can't seem to do this very simple thing! I am trying to display a list of PDF forms in one page that I have saved under a folder called forms under my_project/grails-app/views/forms and want to open the PDF form in a new window when clicked.
In my .gsp file I am trying to access the forms like this:
Form #1
But that's giving me a 404 error.
I have found couple of solutions like this one or this question (which is very similar to mine)...but first of all, i don't need to upload/download the file. Second, i don't need to render the file either. All I want to do is just click the link and open the PDF file in a new window/tab. Am I saving the PDF files in a wrong place? Please help!! Thank you.
Place your file/directory into grails-app/assets so that you have grails-app/assets/forms/form_one.pdf then you can use the resource tag like this:
Form #1
The grails-app/views directory is used for views rendered by controllers, where as the grails-app/assets directory is used for static and pre-processed assets.

How to print .docx,doc,xls,csv in rails 4?

How can I print .docx,doc,xls,csv in rails 4?
I tried window.open and window.print using javascript, but each time when it invokes window.open it downloads the file.
I tried to embed that in an iframe, that also fails.
Displaying a specific type of file isn't something that relies on your application it relies on the browser. In common browsers there is no support to display the file formats you mentioned.
What you can do is implementing some document viewers based on js if they are available for your usage. For example I know there is a plugin viewer.js that provides functionality to convert office and pdf to html. That might help you out... https://developers.box.com/viewer-js-tutorial/
I tried doing this some time back and this is the blog which i refereed. Helped a great deal.
Hope this helps.

How to embed pdf files into browser with links in .cshtml

I'm new to MVC and would like to find out how to view PDF files. Specifically, I have a bunch of PDF files on server. I would like to render links to those PDF files using MVC and allow the user to click on a link to view the PDF file in a browser. Thank you in advance for your help.
You may use some javascript or pdf readers controll.
Look at : http://viewerjs.org/

how to use tinymce with images on my website like stackoverflow does

i have tinymce embedded in my website, so if users want to edit content, then can click on an "EDIT" link and it brings up the content in tinymce editor. when they click "Save", i save the html to a database. this works perfect and avoids them calling me when they need content changes as they can go in directly and next time they reload the main page, it loads up their changed content.
they now want to be able to add their own images. I see there is some image support in tinymce as seen here, but in my case, the images would be on their computer.
So i am looking for some advice on how to handle image support using tinymce on my asp.net mvc website similar to how stackoverflow allows you to upload and include an image in your question all in one step
any suggestions?
I guess you need to take a look here:
Best TinyMce editor Image Manager / File upload for Asp.net Mvc
it has a list of tinyMCE file browsers/uploaders/managers which work with MVC :)
I had a similar issue and solved it by;
Allowing the user to upload images which i then stored in the file system.
Once the image was saved then you could use tinyMCE to link to it.
It's a round-about way of doing it but it worked. If your images are stored on a users computer then you're going to need to implement something like this me thinks as you can't assume you can link to the image and if you can you can't be sure the computer will be on.
Maybe you can give this TinyMCE-plugin a try (the official Moxiecode plugins are quite expensive):
http://www.phpletter.com/Demo/Tinymce-Ajax-File-Manager/
I haven't tested it yet, but it's a free add on that allows uploading and selecting files.
HTML 5 supports embedded images. You can embed image in html code as a base64 string.
Example Code:
<img src="data:image/gif;base64,R0lGODlhDwAPAKECAAAAzMzM/////wAAACwAAAAADwAPAAACIISPeQHsrZ5ModrLlN48CXF8m2iQYmmKqVlRtW4MLwWACH+H09wdGltaXplZCBieSBVbGVhZCBTbWFydFNhdmVyIQAAOw==" alt="Base64 encoded image" width="150" height="150"/>
There is a opensource TinyMCE plugin available in github:
https://github.com/buddyexpress/bdesk_photo

Is there any way to embed a pdf file into an html5 page?

I want to have a web page coded with HTML5, and I want to be able to put a pdf file onto this page so you can view it without having to click on any links to download it separately. Anyone know how to do this?
I want it to keep the text, images, and layout of the pdf file also. If that weren't the case I would just use an image. Thanks!
Edit: This will be hopefully going onto the ipad. So it won't support adobe. I need to just find a way to somehow make the pdf file show up in an html5 page without using a viewer. I want to keep all of its layers. It doesn't have to stay a pdf file when its on the page, I just need to find a way to transfer all of those layers there without having to do this manually with divs for each image, paragraph, etc.
I don't think this is possible without using Flash. Instead, you might want to convert the PDF to a different format (HTML for example) that can be rendered by the browser. There are tools that can do this from the command line, so making a script to do it on your site won't be too difficult.
You can use the embed tag like this:
<embed src="/path/to/your/file.pdf" />
Maybe you could convert the pdf to images on the server and display the images instead of the original pdf. As far as i know, Apache pdfbox can be used to do such a convert.
A little bit late and maybe issuu is gonna fix it soon but for now you can embed with issuu.com using an iframe and your magazine address ending in ?mode=mobile. Tested in ipad:
<iframe width="850px" height="580px" src="http://www.issuu.com/your_username/docs/your_magazine_name?mode=mobile" frameborder="0" allowfullscreen></iframe>
I would like same mobile version loading in desktop so there is no advertising. If you know how to make the browser to think it's an ipad let me know.
This code would directly embed a pdf viewer in a webpage
<object data="path to pdf " type="application/pdf" width="100" height="100">
<p>Alternative text - include a link to the PDF!</p>
</object>
If you are using ASP.NET, this link may be of interest to you.
Browser Based PDF Viewing And Editing
Hosted entirely on your server,
activePDF Portal is an ASP.NET
WebControl that enables your users to
interactively view and modify PDF
documents from any source - adding
comments, form fields, bookmarks, and
more – directly from within a standard
web browser, without requiring any
client-side software such as Adobe
Reader or Flash, or the use of ActiveX
controls.
- http://portal.activepdf.com/
PDFObject looks promising, but it doesn't work on iPads at the moment.

Resources