How to change the position of table in Report Generator?

4 Ansichten (letzte 30 Tage)
Tong Wang
Tong Wang am 27 Jun. 2018
Kommentiert: Tong Wang am 27 Jun. 2018

I set the paper to 'landscape', then i put a table on that, but you can see above the table, there is a big area of blank(red line), i want to move the top of table to green line, how could i do this? I also have the code below.

 import mlreportgen.dom.*
d = Document('formal','pdf');
open(d)
% Set Orientation
s = d.CurrentPageLayout;
s.PageSize.Orientation  ='landscape';
s.PageSize.Height = '8.264in';
s.PageSize.Width = '11.694in';
img = Image(which('b747.jpg'));
img.Style = {ScaleToFit};
table = Table({img, Paragraph('Entry 2')});
table.Border = 'solid';
table.Width = '2in';
table.entry(1,1).Style = {Height('5in'), Width('8in')};
table.entry(1,2).Border = 'solid';
% Add a row
row1 = TableRow;
append(row1, TableEntry('entry 11'));
append(table,row1);
append(d,table);
close(d);
rptview(d.OutputPath);

Akzeptierte Antwort

Rahul Singhal
Rahul Singhal am 27 Jun. 2018
Hi Tong,
The default layout of the page defines the size for the page margins (top, bottom, left, right) to be "1in" each and also the size for headers and footers to be "0.5in" each. This comes out to be the blank area in your report. You can manipulate these sizes to get the desired output. These can be accessed as:
s = d.CurrentPageLayout;
% To change top-margin to "0in"
s.PageMargins.Top = "0in";

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by