2017-10-24 6 views
-1

から1つの空のページを作成します。JasperReportsのは、私はこのようなテンプレートを持っているJDBC

<?xml version="1.0" encoding="UTF-8"?> 
<!-- Created with Jaspersoft Studio version 6.4.3.final using JasperReports Library version 6.4.3 --> 
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Invoice" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4eedbb89-b4f6-4469-9ab6-f642a1688cf7"> 
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/> 
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="localdb"/> 
    <style name="Title" forecolor="#FFFFFF" fontName="Times New Roman" fontSize="50" isBold="false" pdfFontName="Times-Bold"/> 
    <style name="SubTitle" forecolor="#CCCCCC" fontName="Times New Roman" fontSize="18" isBold="false" pdfFontName="Times-Roman"/> 
    <style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/> 
    <style name="Detail" mode="Transparent" fontName="Times New Roman"/> 
    <style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman"> 
     <conditionalStyle> 
      <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression> 
      <style mode="Opaque" backcolor="#EEEFF0"/> 
     </conditionalStyle> 
    </style> 
     ..... 
    <queryString language="SQL"> 
     <![CDATA[SELECT * from test]]> 
    </queryString> 

そして生成するため、このコード:

@Autowired 
private DataSource datasource; 

@RequestMapping(value = "invoice", produces = MediaType.APPLICATION_PDF_VALUE) 
public ResponseEntity createInvoice() throws JRException, SQLException, IOException { 
    InputStream resourceAsStream = PDFReporter.class.getResourceAsStream(BILL_JRXML); 
    assert resourceAsStream != null : "No " + BILL_JRXML + " found!"; 
    JasperReport r = JasperCompileManager.compileReport(resourceAsStream); 
    Map<String, Object> parameters = new HashMap(); 
    Connection connection = datasource.getConnection(); 
    JasperPrint print = JasperFillManager.fillReport(r, parameters, connection); 
    JRPdfExporter exporter = new JRPdfExporter(); 
    exporter.setExporterInput(new SimpleExporterInput(print)); 
    ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
    exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(bos)); 
    exporter.exportReport(); 
    connection.close(); 
    return new ResponseEntity(bos.toByteArray(), HttpStatus.OK); 
} 

しかし、結果は空白になって1ページだけを持つPDFです。

私はPDFをダウンロードし、リードインが%PDF-1.4、リードアウトが%%EOFのPDFをチェックしました。

私はJaspersoft Studioでそれを行うとうまくいきます。

どうしたのですか?

+0

間違った接続(間違ったデータベース)のように見える、または別のテンプレートを使用しています(スタジオでのチェックと同じではありません) –

答えて

0

ああ、テーブルtestは空です。私は空のページを持っていることは決してありませんでした!

関連する問題