How to pass the whole pdf content as response in Restful web services using java platform.
I tried with converting the responses to String and byte array. First case, got registered expression error. In Second case, getting unexpected results.
PDF data should be transferable as a response of a rest-ful request just fine.
Set the correct content type and transfer the binary content of the PDF.
Nothing special about it.
What are you doing right now? Are you using an library?
Describe your "unexepected results".
Describe your "expression error"
Basically, you need to provide a lot more details.
Your responses from the Java platform are most definitely going to be byte arrays in order to provide the PDF. From the server side you need to make sure that MIME types for PDF are registered and that it's providing and accepting the correct headers for PDF.
If you're serving PDF, Java needs to figure out where that is and hosted under the url that you defined your RESTful resource.
If it's dynamic, your PDF library (I've used iText in the past) needs to be able to output the PDF binary and serve it via your defined RESTful resource.
Not sure if this is related to your problem - but I have seen that Adobe Acrobat doesn't handle HTTP Range headers well and if you say you except Ranges it will throw some very weird Range requests and ignore the partial content headers you send back. Just a warning.
Related
I've been reading about some xPages functionality about wrapping a document with DominoDocument.wrap(...) that is supposed to do this for you. However, I am in a stand along Java program.
Is it possible to get the xPages Jar Files to import into my application somehow? I do have the basic Notes Jars working.
it is unlikely you will get this working using the DominoDocument class. when you wrap the Document, it creates a 'DominoRichTextItem', during this process it extracts the attachments to the local filesystem so that the web server can easily serve the content during the user's browsing/editing session.
this attachment extraction process relies on the user's session information, as well as the xpages applications 'persistence service'.
you are better of trying to emulate this idea by using the standard notes API to extract the text/html mime part, and the extracting attachments/inline image mime parts for whatever your purpose
I need a way to generate HTML interface (form), starting from wsdl, to submit web service requests. The request submission is made by server side code. The user fills out the form and posts data.
I am looking for a library (Java) that might help me to write the code.
I'm not trying to create java classes of the web service, I have to generate form fields for any wsdl url.
According to MikeC http://www.soapclient.com/soaptest.html is a tool to create HTML forms from WSDL documents. Unfortunately, its not a Java library and it also had at least one limitation: no multidimensional array support.
But with a little effort you should be able to write an own parser/transformer for your specific use case. See also How to parse WSDL in Java? to find more information about a WSDL parser for JAVA.
Also possible XSLT http://www.ibm.com/developerworks/library/ws-xsltwsdl/.
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
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.
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.