setMaring выполняется как
public override bool SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
{
if ((this.writer != null) && this.writer.IsPaused())
{
return false;
}
this.nextMarginLeft = marginLeft;
this.nextMarginRight = marginRight;
this.nextMarginTop = marginTop;
this.nextMarginBottom = marginBottom;
return true;
}
, поэтому на следующей странице применяется поле.для решения этой проблемы после вызова pdfDocument вызовите newPage () это решение работает для пустого pdfDocument.
using (FileStream msReport = new FileStream(pdfPath, FileMode.Create))
{
using (Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 10f))
{
try
{
//open the stream
pdfDoc.Open();
pdfDoc.setMargin(20f, 20f, 20f, 20f);
pdfDoc.NewPage();
pdfDoc.Close();
}
catch (Exception ex)
{
//handle exception
}
finally
{
}
}
}