Hi mahesh213,
Refer below example. Create string array and add it to the paragraph and then add the paragraph to the table cell.
Namespaces
C#
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
VB.Net
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
Document document = new Document(PageSize.A4, 88f, 88f, 10f, 10f);
using (MemoryStream memoryStream = new MemoryStream())
{
PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
document.Open();
string[] items = { "Persons working as miners, manufacturing or Trade of Explosives, weapons, hazardous materials (e.g. fertilizers, asbestos fiber, toxic gases, pesticides etc.",
"Media/Film stars/Film Associations.",
"TwoPersons who engage in hazardous sports like rafting, mountaineering, underwater diving, deep sea diving, rafting, canoeing, bungee jumping, parachuting, sky diving or any other dangerous sport or activity",
"Insured’s with existing disability.",
"Lawyers/Advocates, Aviation crew and pilots on non-schedule flights, - Law enforcement agencies (including police, paramilitary, military), Politicians, Multi-Level Marketing Companies, Security Guards, Pathology Labs." };
Font font12 = FontFactory.GetFont("Arial", 12, Font.NORMAL, Color.BLACK);
Font font10 = FontFactory.GetFont("Arial", 12, Font.NORMAL, Color.BLACK);
Paragraph paragraph = new Paragraph(" * The quotes stand invalid if the group covered under this policy would be covering any of the following:\n", font12);
for (int i = 0; i < items.Length; i++)
{
paragraph.Add(new Phrase(" \u2022 \u00a0" + items[i] + "\n", font10));
}
PdfPTable table = new PdfPTable(1);
table.TotalWidth = 500f;
table.LockedWidth = true;
table.SetWidths(new float[] { 0.3f });
table.AddCell(paragraph);
document.Add(table);
document.Close();
byte[] bytes = memoryStream.ToArray();
memoryStream.Close();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=Sample.pdf");
Response.ContentType = "application/pdf";
Response.Buffer = true;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.BinaryWrite(bytes);
Response.End();
Response.Close();
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim document As Document = New Document(PageSize.A4, 88F, 88F, 10F, 10F)
Using memoryStream As MemoryStream = New MemoryStream()
Dim writer As PdfWriter = PdfWriter.GetInstance(document, memoryStream)
document.Open()
Dim items As String() = {"Persons working as miners, manufacturing or Trade of Explosives, weapons, hazardous materials (e.g. fertilizers, asbestos fiber, toxic gases, pesticides etc.",
"Media/Film stars/Film Associations.",
"TwoPersons who engage in hazardous sports like rafting, mountaineering, underwater diving, deep sea diving, rafting, canoeing, bungee jumping, parachuting, sky diving or any other dangerous sport or activity",
"Insured’s with existing disability.",
"Lawyers/Advocates, Aviation crew and pilots on non-schedule flights, - Law enforcement agencies (including police, paramilitary, military), Politicians, Multi-Level Marketing Companies, Security Guards, Pathology Labs."}
Dim font12 As Font = FontFactory.GetFont("Arial", 12, Font.NORMAL, Color.BLACK)
Dim font10 As Font = FontFactory.GetFont("Arial", 12, Font.NORMAL, Color.BLACK)
Dim paragraph As Paragraph = New Paragraph(" * The quotes stand invalid if the group covered under this policy would be covering any of the following:" & vbLf, font12)
For i As Integer = 0 To items.Length - 1
paragraph.Add(New Phrase(" • " & items(i) & vbLf, font10))
Next
Dim table As PdfPTable = New PdfPTable(1)
table.TotalWidth = 500F
table.LockedWidth = True
table.SetWidths(New Single() {0.3F})
table.AddCell(paragraph)
document.Add(table)
document.Close()
Dim bytes As Byte() = memoryStream.ToArray()
memoryStream.Close()
Response.Clear()
Response.ContentType = "application/pdf"
Response.AddHeader("Content-Disposition", "attachment; filename=Sample.pdf")
Response.ContentType = "application/pdf"
Response.Buffer = True
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.BinaryWrite(bytes)
Response.End()
Response.Close()
End Using
End Sub