我从Java RESTful Web服务返回PDF文档,但pdf为10 MB。
这是代码
@GET
@Path("/{docid}")
@Produces("application/pdf")
@Consumes({"application/xml","application/json","application/x-www-form-urlencoded"})
public Response getInvoiceDocument(@PathParam("docid") String docObjectId) throws Exception {
DocumentumService documentumService = new DocumentumService(documentumConfigUtil);
DocumentumDocumentBean docDocumentBean = documentumService.getInvoiceDocContent(docObjectId, true);
FileInputStream fileInputStream;
fileInputStream = new FileInputStream(docDocumentBean.getDocFile());
ResponseBuilder responseBuilder = Response.ok((Object) fileInputStream);
responseBuilder.type("application/pdf");
responseBuilder.header("Content-Disposition", "filename=test.pdf");
return responseBuilder.build();
有没有办法压缩PDF然后发送回复?