I made a reporting engine with javascript for my project...
The problem is with printing..
Although with page-break and css i can produce a good looking report, i want to export that report to a pdf in order to be printed better without ,the url,page title and other stuff that browsers add.
Note in Chrome there isnt page setup!!!
I am using java for server side.
i think sending via ajax the Html of the report somehow and return a url for the pdf report maybe...
i am looking for a good tool for this
thank you
If you do send the data server-side, iText is a great free, open source library for generating PDFs from Java.
What I do is generate the report directly to the response stream after setting the content type of the response to application/pdf and setting a Content-Disposition header to either attachment; filename=foo.pdf (if I want to hint to the browser that it should offer a download) or inline; filename=foo.pdf if I want to hint to the browser to show it in the brower's UI.
For what you're doing, perhaps you want to write a file server-side in case someone requests another copy of the report with the same parameters and such, but if not, writing directly to the servlet's OutputStream would be the way to go.
(Caveat: I have to admit not having actually used the Java version of iText, but only because I haven't needed to generate PDFs from Java yet. I'm doing the above using iTextSharp, the .Net port of iText, from server-side Javascript [yes, really] and it works a treat.)
I'd rather generate the report on the server side, based on the data, using JasperReports.
You can send the html to server side and use iText or JasperReports or OpenOffice api to generate a pdf.
It depends on how much you have invested in your Javascript solution. Typically I would agree that it is much better to produce the report server-side since you'll have more options and probably a more maintainable result using Jasper or Docmosis or somesuch.
You could send the html of the page back to the server and have a system there that can read it and render it into PDF, but you've done a round-trip more than you need to, and it sounds like a harder and more fragile way to produce a PDF.
Related
I need to show a graph(piegraph and XYgraph) in HTML file.
I have used some free tool created an image and I am trying to show this on HTML.
But, we need to place this image in shared folder or in a server to get accessed by HTML.Our client is not satisfied with both approaches.
Can some please let me know whether there is any way where I can pass data directly to html file. The data will be in csv file and it may contain some thousands of rows.
Thanks,
There is a Javascript framework that renders really pretty charts: http://www.highcharts.com/
You can use one of many CSV Javascript parsers: Javascript code to parse CSV data
If you then write some javascript code to extract your CSV data, and pass it to highcharts, you've got a very nice interactive chart.
The alternative, if you want to use your existing images, is to encode the images as base64 directly in the html file: http://webcodertools.com/imagetobase64converter/
As an alternative you can also look at the Dojo Toolkit (http://dojotoolkit.org/), its a Javascript toolkit with some really nice features including charting.
This question is related to another one I've posted recently: Check printing with Java/JSP
We're looking for alternatives to how we currently print checks in a Java web application via an applet. It seems the consensus is to use PDF for printing and that itext offers the ability to do so with Java.
However, it's important in our particular case that the checks are "print-only" - the user should not have any ability in the application to save the check (I know a savvy user could do a PrintScreen but we want to cover our rears and make no native functionality in the app to save checks).
I haven't been successful in browsing the web to find out if it's possible to create a PDF with itext in this manner. I have seen posts on restricting permissions in a PDF but what I'm really looking for is a way to disable the ability to save a PDF locally using itext.
Does this functionality exist? If so, could you point me to documentation/code samples on it?
I'm presuming that you're serving this PDF and wishing to print it from within a web application / web site where no out of the ordinary client side plug-ins are installed.
If printing the PDF using conventional means (e.g. Adobe Reader), the PDF MUST be downloaded to the browser's cache to be opened and printed. There is no way around that.
Now you can probably prevent the average Joe from saving the PDF locally via the following technique, but any savvy user will be able to inspect your HTML's source and download the PDF directly.
Output your PDF in iText such that when the PDF is opened, a print action automatically occurs
Put an invisible IFRAME on your HTML page which loads this PDF, but is not visible in the browser to your user
When the user loads your HTML page, the PDF will be loaded in the IFRAME and sent to the users printer (presuming that Adobe Reader is installed in the browser). Yes, the PDF will end up in the browser cache, but the user would have to be savvy enough to both recognize this and then hunt it down in their browser's cache.
If this is not acceptable, you're going to have to look at converting the PDF to another file type (e.g. pages are rendered to images displayed in the browser or perhaps a Flash / Java object that sends each page in the document to the printer directly)
The printWriter class gives some static variables for certain options: PrintWriter
And here is another SO post that might help: iText disable printing/Copying/Saving
I am searching on ways to make a small app using GWT for converting documents
from one format to other.
Mainly these formats .doc , .pdf , .odt , .rtf.. and maybe a couple
more.
Has anyone tried this before??
I came across the library JODConverter but it needs open office to be
already installed and i don't really know how many people have used it
with gwt in past.
Please give me some starting pointers, or if anyone has experience
with this kind of app, do share.
Thanks and regards,
Rohit
I was looking into implementing something like this a few month ago.
Since GWT compiles your code to JavaScript there is no way for you to do that on the client side, JavaScript can't access the file system.
So you would need to upload the file to the server first and do the conversion on the server side and send the converted file back.
I have never heard of JODConverter before, the the library I wanted to use was Apache POI . Unfortunately I can't tell you anything about it, because I haven't tried it yet.
It sounds like JOD Converter is precisely what you need since you're looking at multi format conversions from Java. You would install OpenOffice on your server and link it up with JOD Converter. When a document is uploaded, your application would call JOD Converter to perform the conversion and stream the converted document back to the caller. Alternatively you can put the file somewhere, and send a link (URL) back to the caller so they can fetch the document. You can also look at JOD Reports or Docmosis if you need to manipulate the documents.
GWT is mostly a client side toolkit. Are you trying to make a tool that does all the conversion on the client side, with no help from the server? In that case, you should be looking for JavaScript libraries that can read/convert all those formats. If you are planning to have the user upload their files to the server, then you can use whatever technology you want on the server, and just use GWT for the UI.
We've got an application that displays PDF files in an IFrame at specific Named Destinations. This works well on Windows systems but not Mac. In Safari, with Acrobat, the Named Destination is ignored and the document is displayed at the start.
Does anyone have any suggestions on how we might accomplish the task of displaying this information? Our initial thoughts are to:
Convert the PDF to HTML on the fly and display the HTML version in the IFrame
Convert the PDF on the page referenced to another format such as PNG etc. and display that in the IFrame
Utilize some kind of Java app that allowed us to render the PDF while honouring the Named Destination (not sure if this exists)
Any other ideas on a potential method of better displaying PDF files at Named Destination points that is a little more cross platform?
EDIT: I guess another option is to store the data in XSL/XSLT type format and convert to HTML for veiwing or PDF for saving to the desktop.
Not much help, but I found that alternative ways to display PDF files (other than the Acrobat Reader client) are few and far between. As you say, the commonly accepted way to render PDF's in something that doesn't natively support it seems to be converting it "something else", which is supported (even Acrobat.com does it this way in their Flex client if I remember it correctly).
Even converting the PDF document to other formats may be disappointing - especially if you expect a certain level of quality. It may also introduce server-side performance issues.
I realise this doesn't help anyone much but I'm interested to see if any other suggestions come up. We've dealt with this problem before in the same way, using IFrame controls (but without named destinations) but I'm very much interested in other suggestions/ideas as well.
We have Flex on the front end and Java on the back end. When a user will request for a PDF file, request will go to the Java backend, where a PDF file will be generated using Jasper Reports. What we dont know is how to display this PDF file in browser; since we dont want to use JSP/Servlets etc - It has to be flex only. Any suggestions?
Flash Player cannot natively render PDF files. This is possible using Adobe AIR but not in a Flex application. Your best bet is to call navigateToURL() and open a Servlet in a new browser tab/window. The Servlet can simply write contents of the PDF file to the OutputStream and set the appropriate HTTP headers.
i think this question is old, but it may help others, there's a new library developed by Jasper Forge them selves, which deals with JasperReports directly, i mean it's not a PDF viewer, but a JasperReport exporting tool, you can download it from here
i tried it through using JasperServer, when viewing reports you can choose from different options to export it, one of them is flash, and it's working nice
Well for starters, PDFs don't always display in the browser. It depends on the user's settings. You essentially header them the pdf file and either they download it or a program like Acrobat Reader opens in the browser to display it.
Not sure how this is done in flex, I would imagine if you're using Java one simple servlet could do it.