Page Margin Alignment


#1

hi all,

Thanks to AsposeTeam for helping me very quickly.

i have one more problem in the page margin alignment.like i am getting so much gap in the begining of the page in the pdf file. I don't want that much gap so i want that to be eliminated.Could you please tell me how to avoid that space.

for that i am sending you the image file for wich i want the page with out gap in the begining of this page.

i am sending you the code also..

CODE:

// Put user code to initialize the page here

Aspose.Pdf.License license = new Aspose.Pdf.License();

license.SetLicense("Aspose.Pdf.lic");

EnableViewState=true;

//string strPathCheck="WebForm1.aspx";

//Response.Write("");

DataTable dt = new DataTable("Employee");

dt.Columns.Add("Employee_ID",typeof(Int32));

dt.Columns.Add("Employee_Name",typeof(string));

dt.Columns.Add("Gender",typeof(string));

//Add 2 rows into the DataTable object programmatically

DataRow dr = dt.NewRow();

dr[0] = 1;

dr[1] = "John Smith";

dr[2] = "Male";

dt.Rows.Add(dr);

dr = dt.NewRow();

dr[0] = 2;

dr[1] = "Mary Miller";

dr[2] = "Female";

dt.Rows.Add(dr);

//Instantiate a Pdf instance

Pdf pdf1 = new Pdf();

//Create a section in the Pdf instance

Section sec1 = pdf1.Sections.Add();

//Create a Table object

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

//Add the Table object in the paragraphs collection of the section

sec1.Paragraphs.Add(tab1);

//Set column widths of the table

tab1.ColumnWidths = "40 100 100 100";

//Set default cell border of the table using BorderInfo object

tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All,0.1F);

//Import data into the Table object from the DataTable created above

tab1.ImportDataTable(dt,true,0,1,3,3);

//Get 1st row from the table

Row row1 = tab1.Rows[0];

//Iterate through all cells in the row and set their background color to blue

foreach(Cell curCell in row1.Cells)

curCell.BackgroundColor = new Aspose.Pdf.Color("Blue");

//Save the Pdf

MarginInfo var=new MarginInfo();

var.Bottom=Convert.ToSingle(20);

var.Left =Convert.ToSingle(0.5);

var.Right=Convert.ToSingle(0.5);

var.Top=Convert.ToSingle(20);

pdf1.Save("c:/testing.pdf");

Thanks in advance

Vamsee


#2

Thanks for considering Aspose.

Please refer to the Margin property of Section.PageInfo.

http://www.aspose.com/wiki/default.aspx/Aspose.Pdf/SetPageSizeAndMargins.html