Report generator page break style not working

4 次查看(过去 30 天)
I'm having trouble with page breaks in pdf report generator.
Here is my code:
% Make layout tables
lot1 = Table({tableRun1, '',tableRun2});
lot1.Style = {Width('100%'), Border('solid','black','1px'), ...
ColSep('solid','black','1px'), ...
RowSep('solid','black','1px'), ...
ResizeToFitContents(true)};
lot2 = Table({tableExport1, '',tableExport2});
lot2.Style = [{Width('100%'), Border('solid','black','1px'), ...
ColSep('solid','black','1px'), ...
RowSep('solid','black','1px'), ...
ResizeToFitContents(true)},{PageBreakBefore(1)}];
% Add content to report
add(rpt, lot1);
add(rpt, lot2);
Below is an image of what I'm getting.
The grey is lot1, the orange is lot2, which is splitting between two pages.
Intent is for lot2 to start on the following page. It was working previously until I increased the length of the first element of lot2 by one row.
Many thanks in advance
John
  1 个评论
John Pitman
John Pitman 2023-9-18
In case anyone else has this problem, I found that increasing the margins from 1cm to 2cm rectified the problem and lot2 goes onto the next page as intended.
Still none the wiser as to why increasing the length of tableExport1 from 4 rows to 5 stops the page break from working with the 1cm margins though.

请先登录,再进行评论。

采纳的回答

Yash
Yash 2023-10-3
Hi John,
I understand that you are facing issues while adding page breaks in report generator using MATLAB.
I have reproduced the issue at my end using MATLAB R2022b, I discovered that this issue only arises if the combined size of "lot1" and "lot2" exceeds the page size. If the combined size is smaller, the page break functions as expected.
To overcome this issue, I have identified a workaround that works in both cases. Instead of using the "mlreportgen.dom.PageBreakBefore" class, you can use the "mlreportgen.dom.PageBreak" class.
Refer to the below code for the implementation:
% Create a Page Break Object
breakObj = mlreportgen.dom.PageBreak()
% Add content to report
add(rpt, lot1);
add(rpt, breakObj);
add(rpt, lot2);
The documentation of the "mlreportgen.dom.PageBreak" class is available at the link provided below:
I hope this addresses your query.
Best Regards,
Yash

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Create Model Web Views 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by