our team has a Java REST service that basically creates a PDF when we make a post call to it, and returns the PDF in the response body. Here's a quick look at that service.
@POST
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response generatePDF(String data) {
File file = new File(FILE_PATH);
ResponseBuilder response = Response.ok((Object) file);
response.header("Content-Disposition", "attachment; filename=my_file.pdf");
return response.build();
}
All we want to do is call this service from our Ruby on Rails controller and download the PDF (I'm assuming it will prompt us for a download/open dialog box). I've researched many ways to do this but nothing is working. We've tried different gems, such as Prawn, PDFKit, and WickedPDF, with no luck. We don't need to generate or edit the PDF on the Rails side. We just want a way for the user to either view or download it so they can print it. Any help would be appreciated. Thanks!