Подотчет DynamicReports для изображения получил ширину = -1JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Подотчет DynamicReports для изображения получил ширину = -1

Сообщение Anonymous »

Код: Выделить всё

      DRDataSource callDataSource = new DRDataSource("topK", "userId", "seatId", "usage");
DRDataSource textDataSource = new DRDataSource("topK", "userId", "seatId", "usage");
StyleBuilder borderStyle = Styles.style()
.setBorder(Styles.border(Styles.pen(1f, LineStyle.SOLID)))
.setHorizontalTextAlignment(HorizontalTextAlignment.CENTER);
var topK = col.column("Top k", "topK", type.integerType())
.setTitleStyle(stl.style(stl.fontTimesNewRomanBold()).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER))
.setStyle(borderStyle);
var userId = col.column("User Id", "userId", type.longType())
.setStyle(borderStyle)
.setTitleStyle(stl.style(stl.fontTimesNewRomanBold()).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER));
var seatId = col.column("Seat Id", "seatId", type.longType())
.setStyle(borderStyle)
.setTitleStyle(stl.style(stl.fontTimesNewRomanBold()).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER));
var usage = col.column("Usage", "usage", type.integerType())
.setStyle(borderStyle)
.setTitleStyle(stl.style(stl.fontTimesNewRomanBold()).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER));
JasperReportBuilder callMonthlySubReport = report()
.title(cmp.text("Top %d Usage - %s".formatted(LIMIT, CALL)).setStyle(stl.style(stl.fontTimesNewRoman().boldItalic())))
.setPageFormat(PageType.A4)
.columns(topK, userId, seatId, usage)
.setDataSource(callDataSource);
JasperReportBuilder textMonthlySubReport = report()
.title(cmp.text("Top %d Usage - %s".formatted(LIMIT, TEXT)).setStyle(stl.style(stl.fontTimesNewRoman().boldItalic())))
.setPageFormat(PageType.A4)
.columns(topK, userId, seatId, usage)
.setDataSource(textDataSource);
DRDataSource monthDataSource = new DRDataSource("month", "call", "text", "bill");
TextColumnBuilder monthCol = col.column("Month", "month", type.stringType())
.setStyle(borderStyle)
.setTitleStyle(stl.style(stl.fontTimesNewRomanBold()).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER));
TextColumnBuilder callCol = col.column("Call", "call", type.integerType())
.setStyle(borderStyle)
.setTitleStyle(stl.style(stl.fontTimesNewRomanBold()).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER));
TextColumnBuilder textCol = col.column("Text", "text", type.integerType())
.setStyle(borderStyle)
.setTitleStyle(stl.style(stl.fontTimesNewRomanBold()).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER));
TextColumnBuilder  billCol = col.column("Bill", "bill", type.bigDecimalType())
.setStyle(borderStyle)
.setTitleStyle(stl.style(stl.fontTimesNewRomanBold()).setHorizontalTextAlignment(HorizontalTextAlignment.CENTER));
JasperReportBuilder sixMonthSubReport = report()
.title(cmp.text("Six Month Usage").setStyle(stl.style(stl.fontTimesNewRoman().boldItalic())))
.setPageFormat(PageType.A4)
.columns(monthCol, callCol, textCol, billCol)
.summary(
cht.lineChart()
.setCategory("month", String.class)
.series(cht.serie(callCol), cht.serie(textCol), cht.serie(billCol))
.setCategoryAxisFormat(cht.axisFormat().setLabel("Month"))
.setValueAxisFormat(cht.axisFormat().setLabel("Usage"))
)
.setDataSource(monthDataSource);
FileOutputStream outputStream = new FileOutputStream("/Users/moatable/Desktop/test.jpg");
report()
.pageHeader(cmp.text("Usage Report").setStyle(stl.style(stl.fontTimesNewRomanBold())))
.pageFooter(cmp.pageXofY())
.setPageFormat(PageType.A4)
.setPageMargin(margin(20))
.title(cmp.text("Monthly Usage Report - %s".formatted(month)).setStyle(stl
.style(stl.fontTimesNewRomanBold())))
.detail(cmp.verticalList(
cmp.subreport(callMonthlySubReport),
cmp.subreport(textMonthlySubReport),
cmp.subreport(sixMonthSubReport)
))
.toImage(outputStream, ImageType.JPG);

Код: Выделить всё

java.lang.IllegalArgumentException: Width (-1) and height (842) cannot be 

Подробнее здесь: [url]https://stackoverflow.com/questions/78833012/dynamicreports-subreport-toimage-got-width-1[/url]
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»