我有以下代码,其在 pdf 文件中的输出是:
表格 MTR 17
宪报官员工资单
DDO Code: 703
代码是:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
public partial class new_salary : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";
// Create PDF document
Document pdfDocument = new Document(PageSize.A4, 70, 45, 40, 25);
PdfWriter wri = PdfWriter.GetInstance(pdfDocument, new FileStream("d://JudgeSalary.pdf", FileMode.Create));
PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream);
pdfDocument.Open();
Chunk boo = new Chunk("Form M.T.R. 17");
Paragraph main1 = new Paragraph("Form M.T.R. 17 \nPAY-BILL OF GAZETTED OFFICER");
main1.Alignment = Element.ALIGN_CENTER;
main1.Font.SetStyle(Font.BOLD);
Paragraph main1a = new Paragraph(" DDO Code: 703");
main1a.Alignment = Element.ALIGN_RIGHT;
pdfDocument.Add(main1);
pdfDocument.Add(main1a);
pdfDocument.Close();
HttpContext.Current.Response.End();
}
}
我希望输出为:
**Form M.T.R. 17**
**PAY-BILL OF GAZETTED OFFICER** DDO Code: 703
如何在段落的第 2 行使用“DDO 代码:703”获得上述输出并且没有文本格式。如果我在“para1”中包含“DDO 代码:703”,则文本显示为粗体。我希望此输出居中对齐,接受我想要右对齐的“DDO 代码:703”。
我不希望它显得粗体,也希望它出现在段落的第二行。我该怎么做?