【发布时间】:2016-10-06 10:43:23
【问题描述】:
我正在处理 winforms,需要创建一个 pdf 页面,用户可以在其中输入他的详细信息,我的代码是:
PdfPCell first_form1 = new PdfPCell();
first_form1.AddElement(new Phrase("6) Complete Postal Address " + "\n\n", normalFontBold));
first_form1.AddElement(new Phrase("7) Date of Birth(Proof in the form of birth certificate or school certificate or medical certificate indicating age) " + "\n\n", normalFontBold));
first_form1.AddElement(new Phrase("8) Age (in complete years) as on the date of marriage " + "\n\n", normalFontBold));
first_form1.AddElement(new Phrase("9) Date Of Marriage " + "\n\n", normalFontBold));
first_form1.AddElement(new Phrase("10) Place Of Marriage " + "\n\n", normalFontBold));
PdfPCell second_form1 = new PdfPCell();
second_form1.AddElement(new Phrase(boy_address + "\n\n", normalFontBold));
second_form1.AddElement(new Phrase(boy_dob + "\n\n\n\n", normalFontBold));
second_form1.AddElement(new Phrase(boy_age + "\n\n\n", normalFontBold));
second_form1.AddElement(new Phrase(date_0f_mrg + "\n\n", normalFontBold));
second_form1.AddElement(new Phrase(place_of_mrg + "\n\n", normalFontBold));
PdfPCell third_form1 = new PdfPCell();
third_form1.AddElement(new Phrase(girl_address + "\n\n", normalFontBold));
third_form1.AddElement(new Phrase(girl_dob + "\n\n\n\n", normalFontBold));
third_form1.AddElement(new Phrase(girl_age + "\n\n\n", normalFontBold));
third_form1.AddElement(new Phrase(date_0f_mrg + "\n\n", normalFontBold));
third_form1.AddElement(new Phrase(place_of_mrg + "\n\n", normalFontBold));
detailsTable_form1.AddCell(first_form1);
detailsTable_form1.AddCell(second_form1);
detailsTable_form1.AddCell(third_form1);
// 如果我的地址几乎相等的字符,那么它打印得很好,但是如果我的男孩地址太大,假设它有超过 100 个字符,那么接下来的行的顺序将会改变
【问题讨论】:
-
您不正确地使用
PdfPTable。您正在使用\n在具有行功能时定位文本。使用行! -
我已经提供了答案。它是如此的微不足道,以至于我很惊讶你要我提供示例代码。