Click here to Skip to main content
15,909,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a repeatercontrol on my Aspx page which will be bound with data during run time [from various functions consisting of different queries]. I am trying to export the repeatercontrol to a PDF using iTextSharp. I am able to export but the alignment is not proper...Please guide with solution....
Posted

1 solution

If you are trying too export your repeater data to PDF in table structure then you can use the below code i think it will help you out.
this code will align your data in table structure in Left-bottom manner of each table cell.

C#
Document myDocument = new Document(PageSize.A4);

PdfWriter myPdfWriter = PdfWriter.GetInstance(myDocument, new FileStream(strPDFFilePath, FileMode.Create)); 
myDocument.Open();

myDocument.NewPage();

PdfContentByte myPdfContentByte = myPdfWriter.DirectContent;

PdfPCell myCell; Paragraph myParagraph;

PdfPTable myTable = new PdfPTable(4); 
myTable.WidthPercentage = 100; 
myTable.SetWidths(new int[4] { 25, 25, 25, 25 });

myTable.DefaultCell.BorderWidth = 1; 
myTable.DefaultCell.BorderColor = BaseColor.RED;

for (int i = -100; i < 100; i++) 
{ 
myParagraph = new Paragraph(String.Format("Alignment: {0}", i)); myParagraph.Font.SetFamily("Verdana"); 
myParagraph.Font.SetColor(72, 72, 72); 
myParagraph.Font.Size = 11;
myCell = new PdfPCell();
myCell.AddElement(myParagraph);
myCell.HorizontalAlignment = i;
myCell.VerticalAlignment = i;                    
myTable.AddCell(myCell);

}

myDocument.Add(myTable); 
myDocument.Add(new Chunk(String.Empty)); }

myDocument.Close(); 
 
Share this answer
 
Comments
Member 8405530 26-Apr-12 11:00am    
Thank u ...for ur valuable reply
Khandwawala Hatim 26-Apr-12 11:04am    
Most welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900