我希望将两个段落相互对齐。
Document document = new Document();
document.SetPageSize(iTextSharp.text.PageSize.A4);
iTextSharp.text.pdf.draw.LineSeparator line1 = new iTextSharp.text.pdf.draw.LineSeparator(0f, 100f, iTextSharp.text.Color.BLACK, Element.ALIGN_LEFT, 1);
Paragraph paragraph = new Paragraph("AirNet Network & Datacom Pvt Ltd \n Address :Block no 10 , Bldg no: D/6, \n RK Industrial Park. \n Mumbai -Nasik High Way, \n Thane Dist-42301 \n Tel. No.:022- 1234567890 \n Email: info@airnetnetworks.com \n Url:www.airnetnetworks.com");
Paragraph paragraph1 = new Paragraph("AirNet Network & Datacom Pvt Ltd \n Address :Block no 10 , Bldg no: D/6, \n RK Industrial Park. \n Mumbai -Nasik High Way, \n Thane Dist-42301 \n Tel. No.:022- 1234567890 \n Email: info@airnetnetworks.com \n Url:www.airnetnetworks.com");
PdfWriter.GetInstance(document, new FileStream("G:\\MySamplePDF.pdf", FileMode.Create));
document.Open();
document.Add(jpg);
document.Add(new Chunk(line1));
document.Add(paragraph);
paragraph1.Alignment = Element.ALIGN_RIGHT;
document.Add(paragraph1);
document.Close();
答案 0 :(得分:0)
您可以使用包含2列的PdfPTable
并将每个Paragraph
添加到单元格。
PdfPTable table = new PdfPTable(2);
table.DefaultCell.BorderWidth = 0;
table.AddCell(paragraph);
table.AddCell(paragraph1);
document.Add(table);
您也可以使用ColumnText
。