1

Currently I am working PDF generation. I do not know how to give margin in PDF. I want to set PDF bottom margin 20mm. I am using delivaryTable.SpacingAfter = 10.04f; code

How can I do it?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Azhar
  • 31
  • 2
  • 3
  • 1
    Refer this http://stackoverflow.com/questions/9236931/set-page-margins-with-itextsharp – MahaSwetha Jun 03 '13 at 08:56
  • 1
    Also cf. the [Keyword: Margins](http://itextpdf.com/themes/keyword.php?id=44) which e.g. refers to the [iText in Action — 2nd Edition](http://itextpdf.com/book/) examples [HelloWorldNarrow](http://itextpdf.com/examples/iia.php?id=17) demonstrating how to set margins in the `Document` constructor, and [HelloWorldMirroredMargins](http://itextpdf.com/examples/iia.php?id=22) demonstrating how to set margins using the `Document.setMargin` method. The corresponding c# examples can be found [here](http://kuujinbo.info/iTextInAction2Ed/). – mkl Jun 03 '13 at 10:27

1 Answers1

5

You could set the pdf margins when you instantiate the document object. Here's the syntax constructor:

public Document(
Rectangle pageSize,
float marginLeft,
float marginRight,
float marginTop,
float marginBottom)

Here's a usage example:

Document doc = new Document(PageSize.A4, 20, 20, 20, 20);