Hi moquamar,
You can adjust space by changing Document class properties.
Please refer below sample.
HTML
<asp:Button Text="Save" runat="server" OnClick="Save" />
Namespaces
C#
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
VB.Net
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports System.IO
Code
C#
protected void Save(object sender, EventArgs e)
{
Document document = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
using (MemoryStream memoryStream = new MemoryStream())
{
PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
document.Open();
Paragraph lineSeparator = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1)));
lineSeparator.SetLeading(0.5F, 0.5F);
Paragraph par = new Paragraph(" ");
Paragraph par1 = new Paragraph("A Fair Lending and Equal Employment Opportunity Agency. For assistance: Individuals with disabilities may contact the ADA Administrator at 924-123-4567, TTY 456-765-1234 or ADA@ILoveThisForum.org");
par.SetLeading(0.7F, 0.7F);
document.Add(new Paragraph(" i. How Many words for colours are there in the poem?"));
document.Add(par);
document.Add(par1);
document.Add(lineSeparator);
document.Close();
byte[] bytes = memoryStream.ToArray();
string SharedPath = @"\\(NetworkFolderIP)\Share\USERS\";
File.WriteAllBytes(SharedPath + "Export.pdf", bytes);
}
}
VB.Net
Protected Sub Save(ByVal sender As Object, ByVal e As EventArgs)
Dim document As Document = New Document(PageSize.A4, 88.0F, 88.0F, 10.0F, 10.0F)
Using memoryStream As MemoryStream = New MemoryStream()
Dim writer As PdfWriter = PdfWriter.GetInstance(document, memoryStream)
document.Open()
Dim lineSeparator As Paragraph = New Paragraph(New Chunk(New iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1)))
lineSeparator.SetLeading(0.5F, 0.5F)
Dim par As Paragraph = New Paragraph(" ")
Dim par1 As Paragraph = New Paragraph("A Fair Lending and Equal Employment Opportunity Agency. For assistance: Individuals with disabilities may contact the ADA Administrator at 924-123-4567, TTY 456-765-1234 or ADA@ILoveThisForum.org")
par.SetLeading(0.7F, 0.7F)
document.Add(New Paragraph(" i. How Many words for colours are there in the poem?"))
document.Add(par)
document.Add(par1)
document.Add(lineSeparator)
document.Close()
Dim bytes As Byte() = memoryStream.ToArray()
Dim SharedPath As String = "\\(NetworkFolderIP)\Share\USERS\"
File.WriteAllBytes(SharedPath & "Export.pdf", bytes)
End Using
End Sub
Screenshot