怎样控制导出pdf文件页面的大小?也就是一页A4的大小就是21*29.7cm导出的大小都不固定,
页边距就没法固定,导出代码如下:
string st = "@1.5@1.5@2.5@1.5@0.5@0.5@0@0@0@1@0@Hide@Hide";
string[] ss = st.Substring(1).Split('@');
FarPoint.Web.Spread.PrintInfo prinf = new FarPoint.Web.Spread.PrintInfo();
prinf.Margin = new PrintMargin(0, 0, 0, 0, 0, 0);//.Top = int.Parse(ss[0]);
prinf.Margin.Top = Convert.ToInt32(Convert.ToDouble(ss[0]) * 100 / 2.54);
prinf.Margin.Left = Convert.ToInt32(Convert.ToDouble(ss[2]) * 100 / 2.54);
prinf.Margin.Right = Convert.ToInt32(Convert.ToDouble(ss[3]) * 100 / 2.54);
prinf.Margin.Bottom = Convert.ToInt32(Convert.ToDouble(ss[1]) * 100 / 2.54);
prinf.HeaderHeight = Convert.ToInt32(Convert.ToDouble(ss[4]) * 100 / 2.54);
prinf.FooterHeight = Convert.ToInt32(Convert.ToDouble(ss[5]) * 100 / 2.54);
if (ss[6] == "0")
{
prinf.Centering = FarPoint.Web.Spread.Centering.None;
}
else if (ss[6] == "1")
{
prinf.Centering = FarPoint.Web.Spread.Centering.Horizontal;
}
else if (ss[6] == "2")
{
prinf.Centering = FarPoint.Web.Spread.Centering.Vertical;
}
else if (ss[6] == "3")
{
prinf.Centering = FarPoint.Web.Spread.Centering.Both;
}
if (ss[7] == "1")
{
prinf.Orientation = PrintOrientation.Landscape;
}
else prinf.Orientation = PrintOrientation.Portrait;
if (ss[8] == "1")
{
prinf.ShowBorder = true;
}
else prinf.ShowBorder = false;
if (ss[9] == "1")
{
prinf.ShowColor = true;
}
else prinf.ShowColor = false;
if (ss[10] == "1")
{
prinf.ShowGrid = true;
}
else prinf.ShowGrid = false;
if (ss[11] == "Hide")
{
prinf.ShowRowHeader = PrintHeader.Hide;
}
else if (ss[11] == "Inherit")
{
prinf.ShowRowHeader = PrintHeader.Inherit;
}
else if (ss[11] == "Show")
{
prinf.ShowRowHeader = PrintHeader.Show;
}
if (ss[12] == "Hide")
{
prinf.ShowColumnHeader = PrintHeader.Hide;
}
else if (ss[12] == "Inherit")
{
prinf.ShowColumnHeader = PrintHeader.Inherit;
}
else if (ss[12] == "Show")
{
prinf.ShowColumnHeader = PrintHeader.Show;
}
prinf.SmartPrintPagesTall = Convert.ToInt32(29.7 * 100 / 2.54);
prinf.SmartPrintPagesWide = Convert.ToInt32(21 * 100 / 2.54);
prinf.UseSmartPrint = true;
prinf.ZoomFactor = 1.0f;
prinf.BestFitRows = false;
prinf.BestFitCols = false;
FpSpread1.Sheets[0].PrintInfo = prinf;
filepath = dataDir + "aa.pdf";
FpSpread1.SavePdf(filepath);
|
|