【问题标题】:How to align two paragraphs next to each other如何对齐相邻的两个段落
【发布时间】:2014-10-15 11:54:53
【问题描述】:

我希望两个将两个段落彼此相邻。

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();

【问题讨论】:

标签: .net pdf itextsharp


【解决方案1】:

您可以使用带有 2 列的 PdfPTable,并将每个 Paragraph 添加到一个单元格中。

PdfPTable table = new PdfPTable(2);
table.DefaultCell.BorderWidth = 0;
table.AddCell(paragraph);
table.AddCell(paragraph1);
document.Add(table);

您也可以使用ColumnText

【讨论】:

    猜你喜欢
    • 2020-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多