I am wondering if there is a Java API for HighChart (Not the exporting API) which can generate the svg based on the supplied parameters which can then be later converted to png using Batik without going anywhere near HTTP requests.
At the moment the only way I can think of is to POST to a dummy page with the Chart points then export to SVG and submit to the Export-service with Javascript which converts it into PNG with Batik which in turn returns it as an image stream.
However all I would need is to get the image stream in the JVM supplied by parameters from the DB. The above way needs 2 request-response pairs and apart from that it is not the cleanest solution, I think it generates overhead as this operation would be quite frequent on the server.
You can prepare your own server or use solution described here: http://www.highcharts.com/component/content/article/2-news/52-serverside-generated-charts
Yes you can use API to generate highcharts. Download and try the following project provided by One2team
https://github.com/one2team/highcharts-serverside-export
Related
Right now I'm working on displaying LaTeX generated document with Java.
Strictly speaking, LaTeX source can be used to directly generate two formats:
DVI using latex, the first one to be supported;
PDF using pdflatex, more recent.
However rendering dvi or pdf is not available as far as I know.
Is there any way to handle those formats ? Or maybe others that makes sense ?
There are not enough details with regards to how you wish to "render" DVI or PDF from a LaTeX document. However, you could always just render the pdf using pdflatex and DVI using latex and use ICEpdf for viewing PDFs and javaDVI for viewing DVIs.
Another neat hack to display pdf in a panel is to pass the file path to an embedded web component in the application, and the web component will use whatever pdf rendering tool is available on your machine (Acrobat, Foxit, Preview, etc.)
I remember there was a post about this a long time ago.
I don't think there's a generic way to preview the rendered output without generating the file itself. You can write your own LaTeX engine which caches the output every few seconds and displays that but regardless of the storage, you have to output it somewhere physically and then render the output separately using any of the steps mentioned above.
Another approach is to convert the div output to an svg image file and render that with SVGGraphics2D. That will produce nice scalable results. Dvi files can be converted to svg on the command line (or in a script) using:
dvisvgm --no-fonts input.dvi -o output.svg
For more conversion options see this thread on how to convert pdf to clean svg.
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.
Is it possible send a image or file from an java applet to a php script which produce a pdf.
Until now my java applet has the opportunity that you can save a screenshot of the applet in the users chosen directory and the user can save the test results in form of a pdf. But I want t combine it to one file and I would like to avoid to work with a database.
Yes, it wouldn't even make sense to use a database for this (unless that is the source of the test results). Just upload the screenshot/results as one POST request and then generate PDF with PHP.
So what you want is to render the PDF combining both, the image and the test results right? The processing Framework has a nice Render2PDF function. Integrate it in your project and u wont need this PHP stuff which comes directly from hell.
Radek
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.
I am working on a web application (using Grails) which will generate a gift certificate. I'm thinking of a workflow like this:
The user will pick a template which will be stored as an image.
Then the text (name, date, amount etc) will be overlaid on the image to make the final certificate. There is a set of co-ordinates associated with each template which describes where to put each bit of text.
There is a kind of 'live preview' in the browser which shows the user what the final certificate will look like.
When the user is happy with the results, they download the certificate as a PDF and print it.
Can anyone recommend a library for Java (or Groovy) that will make it easy to do this? I'm not particularly worried about speed, as I suspect that the webapp will only be used by a few people at a time.
UPDATE: in the end I used the iText PDF library to overlay text on a PDF template using PDFStamper.
You can do this with the standard Java 2D graphics libraries - create a BufferedImage from the image, get its Graphics and use drawString() to put the text on top. Of course, the text would then be part of the bitmap in the resulting PDF, and not use the full printing resolution.
In addition to the answers above, I have come across the groovy library GraphicsBuilder and the Grails plugin j2D which are also potiential solutions.
You might consider using Batik to do this as SVG. Your image would be an <img> tag and your text would be one or more <text> tags. There's a converter (called FOP, I believe) which will get you PDF output.