压缩Java REST Web服务中的PDF响应?

时间:2017-08-07 02:27:28

标签: java rest web-services pdf

我从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然后发送回复?

0 个答案:

没有答案