undisputed
undisputed

Reputation: 11

Passing pdf data through REST

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.

Upvotes: 1

Views: 3856

Answers (3)

Gandalf
Gandalf

Reputation: 9855

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.

Upvotes: 0

Synthesis
Synthesis

Reputation: 230

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.

Upvotes: 0

Joachim Sauer
Joachim Sauer

Reputation: 308031

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.

  1. What are you doing right now? Are you using an library?
  2. Describe your "unexepected results".
  3. Describe your "expression error"

Basically, you need to provide a lot more details.

Upvotes: 1

Related Questions