错误PDF jhipster和jasper

时间:2015-11-18 04:53:06

标签: spring spring-boot jasper-reports jhipster

我想将“Spring”的报告发送到角度。我使用“jHipster”作为我项目的基础。我正在使用“OAuth2”

这是我的java控制器。

Map<String, Object> model = new HashMap<String, Object>();

    JasperPrint jasperPrint = JasperFillManager.fillReport(this.getClass().getClassLoader().getResourceAsStream("jasperT/a3.jasper"), model, jasperDTO);
    System.out.println("Creo el jasperPrint");


    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.parseMediaType("application/pdf"));
    String filename = "test.pdf";
    headers.setContentDispositionFormData("inline", filename);
    headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
    ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(JasperExportManager.exportReportToPdf(jasperPrint), headers, HttpStatus.OK);
    System.out.println("Creo el RESPONSE");
    return response;

我的服务。

     angular.module('bbfacturacionserverwebApp').factory('TicketImprimir', function($resource) {
return $resource('api/tickets/imprimir/:id', {}, {
    'get': {
        responseType: 'arraybuffer'

    }

});

});

我的角度控制器。

     $scope.imprimir = function (id) {

    TicketImprimir.get({id: id}, function (result) {
        console.log(result);
        var file = new Blob([result], {type: 'application/pdf'});
        var fileURL = window.URL.createObjectURL(file);
       window.open(fileURL);

    });
};

尝试打开PDF时显示“错误”。这是回应。

curl'http://localhost:8080/api/tickets/imprimir/526?cacheBuster=1447703356141'-H'Cookie:_ga = GA1.1.1401749376.1447187427; NG_TRANSLATE_LANG_KEY =%22es%22'-H'接受编码:gzip,deflate,sdch'-H'接受语言:es-ES,es; q = 0.8,en; q = 0.6,gl; q = 0.4' - H'授权:Bearer xxxxx'-H'接受:application / json,text / plain,/' - H'Referer:http://localhost:8080/'-H'User-Agent:Mozilla / 5.0(Macintosh; Intel Mac OS X) 10_11_1)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 46.0.2490.86 Safari / 537.36'-H'连接:keep-alive' - 压缩

%PDF-1.4%???? 3 0 obj&lt;&gt; stream p4 ?? |?HW?$?рu&amp; b?[?j ?????????????????????? ; PY(?$ E ???? d @ c5?Py ???“?} a?T?N?x ?? w ???????????? ӅJ?uP ?? Fv ?? I?zj?Юh?? A?\?4 \ eE ??? A?> ?? ??#R)?J ?? $ 9p @(?zP ^ Ep?Ez ???????| BQ ?????量F r ??&GT; Bҩ@ B $“˔X4Q S 13 vռ??:电子??? ???9VHʣBñ???? ?@ 1 H 26 F +%H 20 Q &LT; 0 * f] [??? MW ??ѐ;??????AG(T进口K $Ĵ???ù 〜@?{Qy ??? /?bD ?????????????????????????????????????????????????????????????????????????????????????????????? 【J ??? EA&Delta; p&Delta; v&安培;?????v] 4P2Ƅ“G ?? Sd中?? E(!?S 10 L R ????米?? w_R ??? ?a ?? ^ R ???“????????????????????????????????????????????????????? obj&lt;&gt; / Parent 4 0 R / Contents 3 0 R /类型/页面/标签/ S /资源&lt;&gt; /字体&lt;&gt;&gt;&gt; / MediaBox [0 0 595 842] /旋转90&gt;&gt; ; endobj 5 0 obj [1 0 R / XYZ 0 605 0] endobj 2 0 obj&lt;&gt; endobj 4 0 obj&lt;&gt; endobj 6 0 obj&lt;&gt; endobj 7 0 obj&lt;&gt; endobj 8 0 obj&lt;&gt; / Pages 4 0 R&gt;&gt; endobj 9 0 obj&lt;&gt; endobj xref 0 10 0000000000 65535 f 0000000754 00000 n 0000001040 00000 n 0000000015 00000 n 0000001128 00000 n 0000001005 00000 n 0000001191 00000 n 0000001245 00000 n 0000001277 00000 n 0000001380 00000 n预告片&lt;&lt; 24fed746a4c8be3e57800ecb2cc9a4a7&gt;] / Info 9 0 R / Size 10&gt;&gt; startxref 1547 %% EOF

0 个答案:

没有答案