How can I remove the default top margin on a pdf document with itextsharp?

You'll need to set your margins in your Document constructor, like this:

Document pdf = new Document(new Rectangle(288f, 144f), 0, 0, 0, 0); 

You won't need to use the Document.SetMargins() method. I believe you'd use SetMargins()after you create a new page by calling Document.NewPage().


Option 1:

Document doc = new Document();
doc.setMargins(0 , 0 , 0 , 0);

Option 2:

Document pdf = new Document(new Rectangle(595 , 842 ), 0, 0, 0, 0); 

Where, 595x842 is A4 size paper.